Skip to content

Commit

Permalink
Merge pull request #110 from felixonmars/master
Browse files Browse the repository at this point in the history
Support 'Language' header field of PO files
  • Loading branch information
erickwilder committed Aug 5, 2015
2 parents 546025b + 3ce842b commit 56c59d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions babel/messages/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ def _get_mime_headers(self):
else:
headers.append(('PO-Revision-Date', self.revision_date))
headers.append(('Last-Translator', self.last_translator))
if self.locale is not None:
headers.append(('Language', str(self.locale)))
if (self.locale is not None) and ('LANGUAGE' in self.language_team):
headers.append(('Language-Team',
self.language_team.replace('LANGUAGE',
Expand Down Expand Up @@ -457,6 +459,7 @@ def _set_mime_headers(self, headers):
POT-Creation-Date: 1990-04-01 15:30+0000
PO-Revision-Date: 1990-08-03 12:00+0000
Last-Translator: John Doe <[email protected]>
Language: de_DE
Language-Team: de_DE <[email protected]>
Plural-Forms: nplurals=2; plural=(n != 1)
MIME-Version: 1.0
Expand Down
1 change: 1 addition & 0 deletions tests/messages/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ def test_catalog_mime_headers_set_locale():
('POT-Creation-Date', '1990-04-01 15:30+0000'),
('PO-Revision-Date', '1990-08-03 12:00+0000'),
('Last-Translator', 'John Doe <[email protected]>'),
('Language', 'de_DE'),
('Language-Team', 'de_DE <[email protected]>'),
('Plural-Forms', 'nplurals=2; plural=(n != 1)'),
('MIME-Version', '1.0'),
Expand Down
9 changes: 9 additions & 0 deletions tests/messages/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ def test_with_output_dir(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -409,6 +410,7 @@ def test_keeps_catalog_non_fuzzy(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -459,6 +461,7 @@ def test_correct_init_more_than_2_plurals(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: lv_LV\n"
"Language-Team: lv_LV <[email protected]>\n"
"Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
" 2)\n"
Expand Down Expand Up @@ -511,6 +514,7 @@ def test_correct_init_singular_plural_forms(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ja_JP\n"
"Language-Team: ja_JP <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -568,6 +572,7 @@ def test_supports_no_wrap(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -626,6 +631,7 @@ def test_supports_width(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -884,6 +890,7 @@ def test_init_with_output_dir(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -934,6 +941,7 @@ def test_init_singular_plural_forms(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ja_JP\n"
"Language-Team: ja_JP <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -980,6 +988,7 @@ def test_init_more_than_2_plural_forms(self):
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
"PO-Revision-Date: %(date)s\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: lv_LV\n"
"Language-Team: lv_LV <[email protected]>\n"
"Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
" 2)\n"
Expand Down

0 comments on commit 56c59d5

Please sign in to comment.