launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26307
[Merge] ~cjwatson/launchpad:py3-po-file-exports-bytes into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-po-file-exports-bytes into launchpad:master.
Commit message:
Treat PO file exports as bytes
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398020
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-po-file-exports-bytes into launchpad:master.
diff --git a/lib/lp/translations/doc/pofile.txt b/lib/lp/translations/doc/pofile.txt
index c9feb84..4f34ad7 100644
--- a/lib/lp/translations/doc/pofile.txt
+++ b/lib/lp/translations/doc/pofile.txt
@@ -446,7 +446,7 @@ The header is not changed.
>>> for i in range(len(stream_list)):
... if stream_list[i].startswith(b'"Content-Type:'):
- ... print(stream_list[i])
+ ... print(stream_list[i].decode("ASCII"))
"Content-Type: text/plain; charset=EUC-JP\n"
And checking one of the translations, we can see that it's using the
@@ -456,10 +456,8 @@ EUC-JP encoding.
... if (stream_list[i].startswith(b'msgstr') and
... b'prefs.js' in stream_list[i]):
... break
- >>> stream_list[i]
- 'msgstr "\xc0\xdf\xc4\xea\xa4\xce\xa5\xab...\xa5\xba\xa4\xcb
- /etc/mozilla/prefs.js
- \xa4\xac\xcd\xf8\xcd\xd1\xa4\xc7\xa4\xad\xa4\xde\xa4\xb9\xa1\xa3"'
+ >>> print(stream_list[i].decode("EUC-JP"))
+ msgstr "設定のカ...ズに /etc/mozilla/prefs.js が利用できます。"
Now, let's force the UTF-8 encoding.
@@ -470,7 +468,7 @@ We can see that the header has been updated to have UTF-8
>>> for i in range(len(stream_list)):
... if stream_list[i].startswith(b'"Content-Type:'):
- ... print(stream_list[i])
+ ... print(stream_list[i].decode("ASCII"))
"Content-Type: text/plain; charset=UTF-8\n"
And the encoding used is also using UTF-8 chars.
@@ -479,10 +477,8 @@ And the encoding used is also using UTF-8 chars.
... if (stream_list[i].startswith(b'msgstr') and
... b'prefs.js' in stream_list[i]):
... break
- >>> stream_list[i]
- 'msgstr "\xe8\xa8\xad\xe5\xae\x9a\xe3\x81...\xba\xe3\x81\xab
- /etc/mozilla/prefs.js
- \xe3\x81\x8c\xe5\x88\xa9\xe7\x94\xa8\xe3...\x99\xe3\x80\x82"'
+ >>> print(stream_list[i].decode("UTF-8"))
+ msgstr "設定のカ...ズに /etc/mozilla/prefs.js が利用できます。"
There are some situations when a msgid_plural changes, while the msgid
singular remains unchanged.
diff --git a/lib/lp/translations/doc/potemplate.txt b/lib/lp/translations/doc/potemplate.txt
index 08e4217..cdf9515 100644
--- a/lib/lp/translations/doc/potemplate.txt
+++ b/lib/lp/translations/doc/potemplate.txt
@@ -290,11 +290,11 @@ export()
Templates can be exported to its native format.
- >>> for line in potemplate.export().split('\n'):
- ... if 'X-Launchpad-Export-Date' in line:
- ... # Avoid a time bomb in our tests and ignore this field.
- ... continue
- ... print(line)
+ >>> for line in potemplate.export().decode('ASCII').split('\n'):
+ ... if 'X-Launchpad-Export-Date' in line:
+ ... # Avoid a time bomb in our tests and ignore this field.
+ ... continue
+ ... print(line)
#, fuzzy
msgid ""
msgstr ""
diff --git a/lib/lp/translations/utilities/doc/gettext_po_parser_context.txt b/lib/lp/translations/utilities/doc/gettext_po_parser_context.txt
index f096aa6..8afe718 100644
--- a/lib/lp/translations/utilities/doc/gettext_po_parser_context.txt
+++ b/lib/lp/translations/utilities/doc/gettext_po_parser_context.txt
@@ -251,7 +251,7 @@ And for messages with plural forms, it gets all the translations.
Make sure exported files are correct. Exporting a POT file returns exactly
the same contents, except that header is marked fuzzy.
- >>> print(potemplate.export())
+ >>> print(potemplate.export().decode('UTF-8'))
#, fuzzy
msgid ""
msgstr ""
diff --git a/lib/lp/translations/utilities/doc/kde-po-file-format.txt b/lib/lp/translations/utilities/doc/kde-po-file-format.txt
index bb7a636..cff01b6 100644
--- a/lib/lp/translations/utilities/doc/kde-po-file-format.txt
+++ b/lib/lp/translations/utilities/doc/kde-po-file-format.txt
@@ -257,7 +257,7 @@ Make sure all the date constants are replaced with real values in database:
Template export turns it back into a KDE-style PO file:
>>> print(export_with_format(
- ... firefox_potemplate, TranslationFileFormat.KDEPO))
+ ... firefox_potemplate, TranslationFileFormat.KDEPO).decode('UTF-8'))
#, fuzzy
msgid ""
msgstr ""
@@ -308,7 +308,7 @@ does not support messages that are identical in all but the plural, so
those are stripped out.
>>> print(export_with_format(firefox_potemplate,
- ... TranslationFileFormat.PO))
+ ... TranslationFileFormat.PO).decode('UTF-8'))
#, fuzzy
msgid ""
msgstr ""
@@ -498,7 +498,7 @@ other message and its translation:
Exporting a PO template as a KDE PO file joins the context back together:
>>> print(export_with_format(firefox_potemplate,
- ... TranslationFileFormat.KDEPO))
+ ... TranslationFileFormat.KDEPO).decode('UTF-8'))
#, fuzzy
msgid ""
msgstr ""