Skip to content

Commit

Permalink
Add django_only.po file for translators.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphje committed Aug 10, 2014
1 parent f9da05d commit dfa83ee
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ Django translation files using::

_scripts/mergemessages.py

Translators should note that all CLDR data will be automatically overwritten with translations. In the off chance that
a manual override is required, add a comment with the string ``manual`` in it.
This command will also synchronize with file named ``django_only.po``, which can be used by translators to translate
messages (instead of the huge ``django.po`` file that also contains CLDR strings).

Translators should note that all CLDR data will be automatically overwritten with translations.
30 changes: 29 additions & 1 deletion _scripts/mergemessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,26 @@ def handle(self, *args, **options):
try:
self.stdout.write("Parsing language %s" % language)

# Get some files ready
# The pofile is our combined file
pofile = polib.pofile(os.path.join(LOCALE_PATH, lc, 'LC_MESSAGES', 'django.po'))
# The cldrfile contain only messages from CLDR
cldrfile = polib.pofile(os.path.join(LOCALE_PATH, lc, 'LC_MESSAGES', 'cldr.po'))

# The djangofile will only contain messages not from CLDR
try:
djangofile = polib.pofile(os.path.join(LOCALE_PATH, lc, 'LC_MESSAGES', 'django_only.po'))
except IOError:
djangofile = polib.POFile()

# Merge all non-django messages to the djangofile
django_only_messages = polib.POFile()
for entry in pofile:
if cldrfile.find(entry.msgid) is None and not entry.obsolete and not 'fuzzy' in entry.flags:
django_only_messages.append(entry)
djangofile.merge(django_only_messages)
djangofile.save(os.path.join(LOCALE_PATH, lc, 'LC_MESSAGES', 'django_only.po'))

# Add all entries from the CLDR file to the combined file
for entry in cldrfile:
e = pofile.find(entry.msgid)
if e is None:
Expand All @@ -50,6 +67,17 @@ def handle(self, *args, **options):
if 'fuzzy' in e.flags:
e.flags.remove('fuzzy')

# Add entries from the Django file to the combined file
for entry in djangofile:
e = pofile.find(entry.msgid)
# If not in main file, then skip
if e is None:
continue
e.obsolete = entry.obsolete
e.msgstr = entry.msgstr
e.comment = entry.comment
e.flags = entry.flags

pofile.save()
pofile.save_as_mofile(os.path.join(LOCALE_PATH, lc, 'LC_MESSAGES', 'django.mo'))

Expand Down
67 changes: 67 additions & 0 deletions internationalflavor/locale/de/LC_MESSAGES/django_only.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
msgid ""
msgstr ""

#: countries/models.py:13
msgid "A country"
msgstr ""

#: iban/models.py:26
msgid "An International Bank Account Number"
msgstr ""

#: iban/models.py:69
msgid "An International Bank Code"
msgstr ""

#: iban/validators.py:49
msgid "This IBAN does not start with a country code and checksum."
msgstr ""

#: iban/validators.py:55
#, python-format
msgid "%(country)s IBANs are not allowed in this field."
msgstr ""

#: iban/validators.py:59
#, python-format
msgid "This IBAN does not match the requirements for %(country)s ."
msgstr ""

#: iban/validators.py:61
msgid "This IBAN is not for a known country."
msgstr ""

#: iban/validators.py:74
msgid "This IBAN does not have a valid checksum."
msgstr ""

#: iban/validators.py:80
msgid "This Bank Identifier Code (BIC) is invalid."
msgstr ""

#: vat_number/models.py:25
msgid "A number used for VAT registration"
msgstr ""

#: vat_number/validators.py:62
msgid "This VAT number does not start with a country code."
msgstr ""

#: vat_number/validators.py:68
#, python-format
msgid "%(country)s VAT numbers are not allowed in this field."
msgstr ""

#: vat_number/validators.py:70
#, python-format
msgid "This VAT number does not match the requirements for %(country)s."
msgstr ""

#: vat_number/validators.py:76
msgid "This VAT number is not for a known country."
msgstr ""

#: vat_number/validators.py:102
msgid "This VAT number does not exist."
msgstr ""
67 changes: 67 additions & 0 deletions internationalflavor/locale/nl/LC_MESSAGES/django_only.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
msgid ""
msgstr ""

#: countries/models.py:13
msgid "A country"
msgstr ""

#: iban/models.py:26
msgid "An International Bank Account Number"
msgstr ""

#: iban/models.py:69
msgid "An International Bank Code"
msgstr ""

#: iban/validators.py:49
msgid "This IBAN does not start with a country code and checksum."
msgstr ""

#: iban/validators.py:55
#, python-format
msgid "%(country)s IBANs are not allowed in this field."
msgstr ""

#: iban/validators.py:59
#, python-format
msgid "This IBAN does not match the requirements for %(country)s ."
msgstr ""

#: iban/validators.py:61
msgid "This IBAN is not for a known country."
msgstr ""

#: iban/validators.py:74
msgid "This IBAN does not have a valid checksum."
msgstr ""

#: iban/validators.py:80
msgid "This Bank Identifier Code (BIC) is invalid."
msgstr ""

#: vat_number/models.py:25
msgid "A number used for VAT registration"
msgstr ""

#: vat_number/validators.py:62
msgid "This VAT number does not start with a country code."
msgstr ""

#: vat_number/validators.py:68
#, python-format
msgid "%(country)s VAT numbers are not allowed in this field."
msgstr ""

#: vat_number/validators.py:70
#, python-format
msgid "This VAT number does not match the requirements for %(country)s."
msgstr ""

#: vat_number/validators.py:76
msgid "This VAT number is not for a known country."
msgstr ""

#: vat_number/validators.py:102
msgid "This VAT number does not exist."
msgstr ""

0 comments on commit dfa83ee

Please sign in to comment.