Ejemplo n.º 1
0
 def _set_mime_headers(self, headers):
     for name, value in headers:
         name = force_text(name.lower(), encoding=self.charset)
         value = force_text(value, encoding=self.charset)
         if name == 'project-id-version':
             parts = value.split(' ')
             self.project = u' '.join(parts[:-1])
             self.version = parts[-1]
         elif name == 'report-msgid-bugs-to':
             self.msgid_bugs_address = value
         elif name == 'last-translator':
             self.last_translator = value
         elif name == 'language':
             value = value.replace('-', '_')
             self._set_locale(value)
         elif name == 'language-team':
             self.language_team = value
         elif name == 'content-type':
             mimetype, params = parse_header(value)
             if 'charset' in params:
                 self.charset = params['charset'].lower()
         elif name == 'plural-forms':
             _, params = parse_header(' ;' + value)
             self._num_plurals = int(params.get('nplurals', 2))
             self._plural_expr = params.get('plural', '(n != 1)')
         elif name == 'pot-creation-date':
             self.creation_date = _parse_datetime_header(value)
         elif name == 'po-revision-date':
             # Keep the value if it's not the default one
             if 'YEAR' not in value:
                 self.revision_date = _parse_datetime_header(value)
Ejemplo n.º 2
0
 def _set_mime_headers(self, headers):
     for name, value in headers:
         name = force_text(name.lower(), encoding=self.charset)
         value = force_text(value, encoding=self.charset)
         if name == 'project-id-version':
             parts = value.split(' ')
             self.project = u' '.join(parts[:-1])
             self.version = parts[-1]
         elif name == 'report-msgid-bugs-to':
             self.msgid_bugs_address = value
         elif name == 'last-translator':
             self.last_translator = value
         elif name == 'language':
             value = value.replace('-', '_')
             self._set_locale(value)
         elif name == 'language-team':
             self.language_team = value
         elif name == 'content-type':
             mimetype, params = parse_header(value)
             if 'charset' in params:
                 self.charset = params['charset'].lower()
         elif name == 'plural-forms':
             _, params = parse_header(' ;' + value)
             self._num_plurals = int(params.get('nplurals', 2))
             self._plural_expr = params.get('plural', '(n != 1)')
         elif name == 'pot-creation-date':
             self.creation_date = _parse_datetime_header(value)
         elif name == 'po-revision-date':
             # Keep the value if it's not the default one
             if 'YEAR' not in value:
                 self.revision_date = _parse_datetime_header(value)
Ejemplo n.º 3
0
 def _set_mime_headers(self, headers):
     for name, value in headers:
         name = force_text(name.lower(), encoding=self.charset)
         value = force_text(value, encoding=self.charset)
         if name == "project-id-version":
             parts = value.split(" ")
             self.project = u" ".join(parts[:-1])
             self.version = parts[-1]
         elif name == "report-msgid-bugs-to":
             self.msgid_bugs_address = value
         elif name == "last-translator":
             self.last_translator = value
         elif name == "language":
             value = value.replace("-", "_")
             self._set_locale(value)
         elif name == "language-team":
             self.language_team = value
         elif name == "content-type":
             mimetype, params = parse_header(value)
             if "charset" in params:
                 self.charset = params["charset"].lower()
         elif name == "plural-forms":
             _, params = parse_header(" ;" + value)
             self._num_plurals = int(params.get("nplurals", 2))
             self._plural_expr = params.get("plural", "(n != 1)")
         elif name == "pot-creation-date":
             self.creation_date = _parse_datetime_header(value)
         elif name == "po-revision-date":
             # Keep the value if it's not the default one
             if "YEAR" not in value:
                 self.revision_date = _parse_datetime_header(value)