# individuals. For the exact contribution history, see the revision
# history and logs, available at http://babel.edgewall.org/log/.
-from datetime import datetime
-import time
import unittest
+from datetime import datetime
from io import BytesIO
from babel import __version__ as VERSION
except UnknownLocaleError:
# Just an alias? Not what we're testing here, let's continue
continue
- po_file = (u"""\
-# %(english_name)s translations for TestProject.
+ date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale)
+ plural = PLURALS[_locale][0]
+ po_file = (f"""\
+# {locale.english_name} translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\\n"
-"PO-Revision-Date: %(date)s\\n"
+"PO-Revision-Date: {date}\\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n"
+"Language-Team: {_locale} <LL@li.org>\n"
+"Plural-Forms: nplurals={plural}; plural={plural};\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=utf-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
-"Generated-By: Babel %(version)s\\n"
+"Generated-By: Babel {VERSION}\\n"
#. This will be a translator comment,
#. that will include several lines
msgid_plural "foobars"
msgstr[0] ""
-""" % dict(locale=_locale,
- english_name=locale.english_name,
- version=VERSION,
- year=time.strftime('%Y'),
- date=format_datetime(datetime.now(LOCALTZ),
- 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale=_locale),
- num_plurals=PLURALS[_locale][0],
- plural_expr=PLURALS[_locale][0])).encode('utf-8')
+""").encode('utf-8')
# This test will fail for revisions <= 406 because so far
# catalog.num_plurals was neglected
except UnknownLocaleError:
# Just an alias? Not what we're testing here, let's continue
continue
- po_file = (u"""\
-# %(english_name)s translations for TestProject.
+ po_file = f"""\
+# {locale.english_name} translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\\n"
-"PO-Revision-Date: %(date)s\\n"
+"PO-Revision-Date: {date}\\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
-"Language-Team: %(locale)s <LL@li.org>\\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\\n"
+"Language-Team: {_locale} <LL@li.org>\\n"
+"Plural-Forms: nplurals={num_plurals}; plural={plural_expr};\\n"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=utf-8\\n"
"Content-Transfer-Encoding: 8bit\\n"
-"Generated-By: Babel %(version)s\\n"
+"Generated-By: Babel {VERSION}\\n"
#. This will be a translator comment,
#. that will include several lines
msgstr[1] ""
msgstr[2] ""
-""" % dict(locale=_locale,
- english_name=locale.english_name,
- version=VERSION,
- year=time.strftime('%Y'),
- date=date,
- num_plurals=num_plurals,
- plural_expr=plural_expr)).encode('utf-8')
+""".encode('utf-8')
# we should be adding the missing msgstr[0]
# This test will fail for revisions <= 406 because so far
def test_3_num_plurals_checkers(self):
for _locale in [p for p in PLURALS if PLURALS[p][0] == 3]:
- po_file = (r"""\
-# %(english_name)s translations for TestProject.
+ plural = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale)
+ english_name = Locale.parse(_locale).english_name
+ po_file = fr"""\
+# {english_name} translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {plural}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\n"
+"Plural-Forms: nplurals={PLURALS[_locale][0]}; plural={PLURALS[_locale][0]};\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator comment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % dict(locale=_locale,
- english_name=Locale.parse(_locale).english_name,
- version=VERSION,
- year=time.strftime('%Y'),
- date=format_datetime(datetime.now(LOCALTZ),
- 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale=_locale),
- num_plurals=PLURALS[_locale][0],
- plural_expr=PLURALS[_locale][0])).encode('utf-8')
+""".encode('utf-8')
# This test will fail for revisions <= 406 because so far
# catalog.num_plurals was neglected
def test_4_num_plurals_checkers(self):
for _locale in [p for p in PLURALS if PLURALS[p][0] == 4]:
- po_file = (r"""\
-# %(english_name)s translations for TestProject.
+ date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale)
+ english_name = Locale.parse(_locale).english_name
+ plural = PLURALS[_locale][0]
+ po_file = fr"""\
+# {english_name} translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\n"
+"Plural-Forms: nplurals={plural}; plural={plural};\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator comment,
#. that will include several lines
msgstr[1] ""
msgstr[2] ""
-""" % dict(locale=_locale,
- english_name=Locale.parse(_locale).english_name,
- version=VERSION,
- year=time.strftime('%Y'),
- date=format_datetime(datetime.now(LOCALTZ),
- 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale=_locale),
- num_plurals=PLURALS[_locale][0],
- plural_expr=PLURALS[_locale][0])).encode('utf-8')
+""".encode('utf-8')
# This test will fail for revisions <= 406 because so far
# catalog.num_plurals was neglected
def test_5_num_plurals_checkers(self):
for _locale in [p for p in PLURALS if PLURALS[p][0] == 5]:
- po_file = (r"""\
-# %(english_name)s translations for TestProject.
+ date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale)
+ english_name = Locale.parse(_locale).english_name
+ plural = PLURALS[_locale][0]
+ po_file = fr"""\
+# {english_name} translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\n"
+"Plural-Forms: nplurals={plural}; plural={plural};\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator comment,
#. that will include several lines
msgstr[2] ""
msgstr[3] ""
-""" % dict(locale=_locale,
- english_name=Locale.parse(_locale).english_name,
- version=VERSION,
- year=time.strftime('%Y'),
- date=format_datetime(datetime.now(LOCALTZ),
- 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale=_locale),
- num_plurals=PLURALS[_locale][0],
- plural_expr=PLURALS[_locale][0])).encode('utf-8')
+""".encode('utf-8')
# This test will fail for revisions <= 406 because so far
# catalog.num_plurals was neglected
def test_6_num_plurals_checkers(self):
for _locale in [p for p in PLURALS if PLURALS[p][0] == 6]:
- po_file = (r"""\
-# %(english_name)s translations for TestProject.
+ english_name = Locale.parse(_locale).english_name
+ date = format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale=_locale)
+ plural = PLURALS[_locale][0]
+ po_file = fr"""\
+# {english_name} translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: %(locale)s <LL@li.org>\n"
-"Plural-Forms: nplurals=%(num_plurals)s; plural=%(plural_expr)s;\n"
+"Language-Team: {_locale} <LL@li.org>\n"
+"Plural-Forms: nplurals={plural}; plural={plural};\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator comment,
#. that will include several lines
msgstr[3] ""
msgstr[4] ""
-""" % dict(locale=_locale,
- english_name=Locale.parse(_locale).english_name,
- version=VERSION,
- year=time.strftime('%Y'),
- date=format_datetime(datetime.now(LOCALTZ),
- 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale=_locale),
- num_plurals=PLURALS[_locale][0],
- plural_expr=PLURALS[_locale][0])).encode('utf-8')
+""".encode('utf-8')
# This test will fail for revisions <= 406 because so far
# catalog.num_plurals was neglected
self.assert_pot_file_exists()
- expected_content = r"""# Translations template for TestProject.
-# Copyright (C) %(year)s FooBar, Inc.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Translations template for TestProject.
+# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
+# FIRST AUTHOR <EMAIL@ADDRESS>, {time.strftime('%Y')}.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
-"POT-Creation-Date: %(date)s\n"
+"POT-Creation-Date: {date}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. TRANSLATOR: This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'year': time.strftime('%Y'),
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(pot_file) as f:
actual_content = f.read()
assert expected_content == actual_content
self.assert_pot_file_exists()
- expected_content = r"""# Translations template for TestProject.
-# Copyright (C) %(year)s FooBar, Inc.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Translations template for TestProject.
+# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
+# FIRST AUTHOR <EMAIL@ADDRESS>, {time.strftime('%Y')}.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
-"POT-Creation-Date: %(date)s\n"
+"POT-Creation-Date: {date}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. TRANSLATOR: This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'year': time.strftime('%Y'),
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(pot_file) as f:
actual_content = f.read()
assert expected_content == actual_content
self.assert_pot_file_exists()
- expected_content = r"""# Translations template for TestProject.
-# Copyright (C) %(year)s FooBar, Inc.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Translations template for TestProject.
+# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
+# FIRST AUTHOR <EMAIL@ADDRESS>, {time.strftime('%Y')}.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
-"POT-Creation-Date: %(date)s\n"
+"POT-Creation-Date: {date}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. TRANSLATOR: This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'year': time.strftime('%Y'),
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(pot_file) as f:
actual_content = f.read()
assert expected_content == actual_content
po_file = _po_file('en_US')
assert os.path.isfile(po_file)
- expected_content = r"""# English (United States) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# English (United States) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
po_file = _po_file('en_US')
assert os.path.isfile(po_file)
- expected_content = r"""# English (United States) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# English (United States) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
po_file = _po_file('lv_LV')
assert os.path.isfile(po_file)
- expected_content = r"""# Latvian (Latvia) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Latvian (Latvia) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: lv_LV\n"
"Language-Team: lv_LV <LL@li.org>\n"
-"Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 :"
" 2);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgstr[1] ""
msgstr[2] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
po_file = _po_file('ja_JP')
assert os.path.isfile(po_file)
- expected_content = r"""# Japanese (Japan) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='ja_JP')
+ expected_content = fr"""# Japanese (Japan) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ja_JP\n"
"Language-Team: ja_JP <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgid_plural "foobars"
msgstr[0] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='ja_JP')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
po_file = _po_file('en_US')
assert os.path.isfile(po_file)
- expected_content = r"""# English (United States) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en_US')
+ expected_content = fr"""# English (United States) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
#: project/file1.py:8
-msgid %(long_message)s
+msgid {long_message}
msgstr ""
#: project/file2.py:9
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en_US'),
- 'long_message': long_message}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
po_file = _po_file('en_US')
assert os.path.isfile(po_file)
- expected_content = r"""# English (United States) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en_US')
+ expected_content = fr"""# English (United States) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
#: project/file1.py:8
-msgid %(long_message)s
+msgid {long_message}
msgstr ""
#: project/file2.py:9
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en_US'),
- 'long_message': long_message}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
'-c', 'TRANSLATOR', '-c', 'TRANSLATORS:',
'-o', pot_file, 'project'])
self.assert_pot_file_exists()
- expected_content = r"""# Translations template for TestProject.
-# Copyright (C) %(year)s FooBar, Inc.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Translations template for TestProject.
+# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
+# FIRST AUTHOR <EMAIL@ADDRESS>, {time.strftime('%Y')}.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
-"POT-Creation-Date: %(date)s\n"
+"POT-Creation-Date: {date}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. TRANSLATOR: This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'year': time.strftime('%Y'),
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(pot_file) as f:
actual_content = f.read()
assert expected_content == actual_content
'-c', 'TRANSLATOR', '-c', 'TRANSLATORS:',
'-o', pot_file, 'project'])
self.assert_pot_file_exists()
- expected_content = r"""# Translations template for TestProject.
-# Copyright (C) %(year)s FooBar, Inc.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Translations template for TestProject.
+# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
+# FIRST AUTHOR <EMAIL@ADDRESS>, {time.strftime('%Y')}.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
-"POT-Creation-Date: %(date)s\n"
+"POT-Creation-Date: {date}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. TRANSLATOR: This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'year': time.strftime('%Y'),
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(pot_file) as f:
actual_content = f.read()
assert expected_content == actual_content
'-c', 'TRANSLATOR', '-c', 'TRANSLATORS:',
'-o', pot_file, file_to_extract])
self.assert_pot_file_exists()
- expected_content = r"""# Translations template for TestProject.
-# Copyright (C) %(year)s FooBar, Inc.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Translations template for TestProject.
+# Copyright (C) {time.strftime('%Y')} FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
-# FIRST AUTHOR <EMAIL@ADDRESS>, %(year)s.
+# FIRST AUTHOR <EMAIL@ADDRESS>, {time.strftime('%Y')}.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
-"POT-Creation-Date: %(date)s\n"
+"POT-Creation-Date: {date}\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#: project/file2.py:9
msgid "foobar"
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'year': time.strftime('%Y'),
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(pot_file) as f:
actual_content = f.read()
assert expected_content == actual_content
'-d', os.path.join(i18n_dir),
'-i', os.path.join(i18n_dir, 'messages.pot')])
assert os.path.isfile(po_file)
- expected_content = r"""# English (United States) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# English (United States) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en_US\n"
"Language-Team: en_US <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgstr[0] ""
msgstr[1] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
'-d', os.path.join(i18n_dir),
'-i', os.path.join(i18n_dir, 'messages.pot')])
assert os.path.isfile(po_file)
- expected_content = r"""# Japanese (Japan) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Japanese (Japan) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ja_JP\n"
"Language-Team: ja_JP <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgid_plural "foobars"
msgstr[0] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content
'-d', i18n_dir,
'-i', os.path.join(i18n_dir, 'messages.pot')])
assert os.path.isfile(po_file)
- expected_content = r"""# Latvian (Latvia) translations for TestProject.
+ date = format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en')
+ expected_content = fr"""# Latvian (Latvia) translations for TestProject.
# Copyright (C) 2007 FooBar, Inc.
# This file is distributed under the same license as the TestProject
# project.
"Project-Id-Version: TestProject 0.1\n"
"Report-Msgid-Bugs-To: bugs.address@email.tld\n"
"POT-Creation-Date: 2007-04-01 15:30+0200\n"
-"PO-Revision-Date: %(date)s\n"
+"PO-Revision-Date: {date}\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: lv_LV\n"
"Language-Team: lv_LV <LL@li.org>\n"
-"Plural-Forms: nplurals=3; plural=(n%%10==1 && n%%100!=11 ? 0 : n != 0 ? 1 :"
+"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 :"
" 2);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
-"Generated-By: Babel %(version)s\n"
+"Generated-By: Babel {VERSION}\n"
#. This will be a translator coment,
#. that will include several lines
msgstr[1] ""
msgstr[2] ""
-""" % {'version': VERSION,
- 'date': format_datetime(datetime(1994, 11, 11, 00, 00), 'yyyy-MM-dd HH:mmZ',
- tzinfo=LOCALTZ, locale='en')}
+"""
with open(po_file) as f:
actual_content = f.read()
assert expected_content == actual_content