From e23cb29673a449e160f938f5345ecab6be2b28d1 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 28 Jul 2013 23:35:30 +0200 Subject: [PATCH 1/6] Added another testcase for subtag expansion. --- tests/test_core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_core.py b/tests/test_core.py index 160515941..b4a1ac575 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -102,6 +102,11 @@ def test_parse_likely_subtags(self): assert l.territory == 'CN' assert l.script == 'Hans' + l = Locale.parse('zh_SG') + assert l.language == 'zh' + assert l.territory == 'SG' + assert l.script == 'Hans' + l = Locale.parse('und_AT') assert l.language == 'de' assert l.territory == 'AT' From 2f1236f46ba7617a4f9d6ebe7e67e4e454ca90d2 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 29 Jul 2013 11:26:19 +0200 Subject: [PATCH 2/6] Fixed a bug on Python 3 when writing to stdout --- CHANGES | 2 ++ babel/messages/frontend.py | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 13f1ad8a6..a45a24879 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,8 @@ Version 1.3 This primarily makes ``zh_CN`` work again which was broken due to how it was defined in the likely subtags combined with our broken resolving. This fixes #37. +- Fixed a bug that caused pybabel to break when writing to stdout + on Python 3. Version 1.2 ----------- diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index 3cec787dc..144bc98a1 100755 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -35,7 +35,7 @@ from babel.messages.mofile import write_mo from babel.messages.pofile import read_po, write_po from babel.util import odict, LOCALTZ -from babel._compat import string_types, BytesIO +from babel._compat import string_types, BytesIO, PY2 class compile_catalog(Command): @@ -826,7 +826,7 @@ def extract(self, argv): help='path to the output POT file') parser.add_option('-w', '--width', dest='width', type='int', help="set output line width (default 76)") - parser.add_option('--no-wrap', dest='no_wrap', action = 'store_true', + parser.add_option('--no-wrap', dest='no_wrap', action='store_true', help='do not break long message lines, longer than ' 'the output line width, into several lines') parser.add_option('--sort-output', dest='sort_output', @@ -921,16 +921,25 @@ def callback(filename, method, options): catalog.add(message, None, [(filepath, lineno)], auto_comments=comments, context=context) + catalog_charset = catalog.charset if options.output not in (None, '-'): self.log.info('writing PO template file to %s' % options.output) outfile = open(options.output, 'wb') close_output = True else: outfile = sys.stdout + + # This is a bit of a hack on Python 3. stdout is a text stream so + # we need to find the underlying file when we write the PO. In + # later versions of Babel we want the write_po function to accept + # text or binary streams and automatically adjust the encoding. + if not PY2 and hasattr(outfile, 'buffer'): + catalog.charset = outfile.encoding + outfile = outfile.buffer.raw + close_output = False try: - print(outfile) write_po(outfile, catalog, width=options.width, no_location=options.no_location, omit_header=options.omit_header, @@ -939,6 +948,7 @@ def callback(filename, method, options): finally: if close_output: outfile.close() + catalog.charset = catalog_charset def init(self, argv): """Subcommand for creating new message catalogs from a template. From 62b866e69ab36a93b6a61353faadd4aa5cc54482 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 29 Jul 2013 11:34:37 +0200 Subject: [PATCH 3/6] Added a missing changelog entry --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index a45a24879..675851120 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,8 @@ Version 1.3 our broken resolving. This fixes #37. - Fixed a bug that caused pybabel to break when writing to stdout on Python 3. +- Removed a stray print that was causing issues when writing to + stdout for message catalogs. Version 1.2 ----------- From 6337beb1ae117cac6d87a3e0f062831b9eafceda Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 29 Jul 2013 13:33:11 +0200 Subject: [PATCH 4/6] Release is today --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 675851120..496f519bb 100644 --- a/CHANGES +++ b/CHANGES @@ -4,7 +4,7 @@ Babel Changelog Version 1.3 ----------- -(bugfix release, release date to be decided) +(bugfix release, released on July 29th 2013) - Fixed a bug in likely-subtag resolving for some common locales. This primarily makes ``zh_CN`` work again which was broken From 62975daac12602efae44d9fc9bf62fce373778b9 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 29 Jul 2013 13:33:20 +0200 Subject: [PATCH 5/6] Bump version number to 1.3 --- babel/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/babel/__init__.py b/babel/__init__.py index 3b9f6a2eb..dd9f17e04 100644 --- a/babel/__init__.py +++ b/babel/__init__.py @@ -21,4 +21,4 @@ negotiate_locale, parse_locale, get_locale_identifier -__version__ = '1.3-dev' +__version__ = '1.3' diff --git a/setup.py b/setup.py index d61e0d33b..4a57551f7 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def run(self): setup( name='Babel', - version='1.3-dev', + version='1.3', description='Internationalization utilities', long_description=\ """A collection of tools for internationalizing Python applications.""", From c3a7bf10158748aea1b8ce430e5f3f1cf4f1ce0f Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Mon, 29 Jul 2013 13:33:55 +0200 Subject: [PATCH 6/6] Ready for 1.4 --- babel/__init__.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/babel/__init__.py b/babel/__init__.py index dd9f17e04..046bdc012 100644 --- a/babel/__init__.py +++ b/babel/__init__.py @@ -21,4 +21,4 @@ negotiate_locale, parse_locale, get_locale_identifier -__version__ = '1.3' +__version__ = '1.4-dev' diff --git a/setup.py b/setup.py index 4a57551f7..7a566ab5c 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def run(self): setup( name='Babel', - version='1.3', + version='1.4-dev', description='Internationalization utilities', long_description=\ """A collection of tools for internationalizing Python applications.""",