Commit a33cb2cd by Ned Batchelder

Merge pull request #2707 from edx/ned/clean-up-i18n-tools

Ned/clean up i18n tools
parents a8c60259 d3c75654
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.1a\n" "Project-Id-Version: 0.1a\n"
"Report-Msgid-Bugs-To: openedx-translation@googlegroups.com\n" "Report-Msgid-Bugs-To: openedx-translation@googlegroups.com\n"
"POT-Creation-Date: 2014-02-25 10:10-0800\n" "POT-Creation-Date: 2014-02-25 14:01-0500\n"
"PO-Revision-Date: 2014-02-25 18:11:53.548896\n" "PO-Revision-Date: 2014-02-25 19:01:45.260096\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: openedx-translation <openedx-translation@googlegroups.com>\n" "Language-Team: openedx-translation <openedx-translation@googlegroups.com>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
...@@ -538,12 +538,10 @@ msgid "Are you sure you want to delete this response?" ...@@ -538,12 +538,10 @@ msgid "Are you sure you want to delete this response?"
msgstr "Àré ýöü süré ýöü wänt tö délété thïs réspönsé? Ⱡ'σяєм ιρѕυм #" msgstr "Àré ýöü süré ýöü wänt tö délété thïs réspönsé? Ⱡ'σяєм ιρѕυм #"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "%s ago" msgid "%s ago"
msgstr "%s ägö Ⱡ'σяєм ιρѕ#" msgstr "%s ägö Ⱡ'σяєм ιρѕ#"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "%s from now" msgid "%s from now"
msgstr "%s fröm nöw Ⱡ#" msgstr "%s fröm nöw Ⱡ#"
...@@ -556,7 +554,6 @@ msgid "about a minute" ...@@ -556,7 +554,6 @@ msgid "about a minute"
msgstr "äßöüt ä mïnüté Ⱡ'#" msgstr "äßöüt ä mïnüté Ⱡ'#"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "%d minute" msgid "%d minute"
msgid_plural "%d minutes" msgid_plural "%d minutes"
msgstr[0] "%d mïnüté #" msgstr[0] "%d mïnüté #"
...@@ -567,7 +564,6 @@ msgid "about an hour" ...@@ -567,7 +564,6 @@ msgid "about an hour"
msgstr "äßöüt än höür Ⱡ'#" msgstr "äßöüt än höür Ⱡ'#"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "about %d hour" msgid "about %d hour"
msgid_plural "about %d hours" msgid_plural "about %d hours"
msgstr[0] "äßöüt %d höür Ⱡ'#" msgstr[0] "äßöüt %d höür Ⱡ'#"
...@@ -578,7 +574,6 @@ msgid "a day" ...@@ -578,7 +574,6 @@ msgid "a day"
msgstr "ä däý Ⱡ'σяєм ι#" msgstr "ä däý Ⱡ'σяєм ι#"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "%d day" msgid "%d day"
msgid_plural "%d days" msgid_plural "%d days"
msgstr[0] "%d däý Ⱡ'σяєм ιρѕ#" msgstr[0] "%d däý Ⱡ'σяєм ιρѕ#"
...@@ -589,7 +584,6 @@ msgid "about a month" ...@@ -589,7 +584,6 @@ msgid "about a month"
msgstr "äßöüt ä mönth Ⱡ'#" msgstr "äßöüt ä mönth Ⱡ'#"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "%d month" msgid "%d month"
msgid_plural "%d months" msgid_plural "%d months"
msgstr[0] "%d mönth #" msgstr[0] "%d mönth #"
...@@ -600,19 +594,16 @@ msgid "about a year" ...@@ -600,19 +594,16 @@ msgid "about a year"
msgstr "äßöüt ä ýéär Ⱡ#" msgstr "äßöüt ä ýéär Ⱡ#"
#: common/static/js/src/jquery.timeago.locale.js #: common/static/js/src/jquery.timeago.locale.js
#, c-format
msgid "%d year" msgid "%d year"
msgid_plural "%d years" msgid_plural "%d years"
msgstr[0] "%d ýéär #" msgstr[0] "%d ýéär #"
msgstr[1] "%d ýéärs #" msgstr[1] "%d ýéärs #"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "Available %s" msgid "Available %s"
msgstr "Àväïläßlé %s Ⱡ#" msgstr "Àväïläßlé %s Ⱡ#"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "" msgid ""
"This is the list of available %s. You may choose some by selecting them in " "This is the list of available %s. You may choose some by selecting them in "
"the box below and then clicking the \"Choose\" arrow between the two boxes." "the box below and then clicking the \"Choose\" arrow between the two boxes."
...@@ -622,7 +613,6 @@ msgstr "" ...@@ -622,7 +613,6 @@ msgstr ""
"Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α∂ιρι#" "Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α∂ιρι#"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "Type into this box to filter down the list of available %s." msgid "Type into this box to filter down the list of available %s."
msgstr "" msgstr ""
"Týpé ïntö thïs ßöx tö fïltér döwn thé lïst öf äväïläßlé %s. Ⱡ'σяєм ιρѕυм " "Týpé ïntö thïs ßöx tö fïltér döwn thé lïst öf äväïläßlé %s. Ⱡ'σяєм ιρѕυм "
...@@ -637,7 +627,6 @@ msgid "Choose all" ...@@ -637,7 +627,6 @@ msgid "Choose all"
msgstr "Çhöösé äll Ⱡ#" msgstr "Çhöösé äll Ⱡ#"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "Click to choose all %s at once." msgid "Click to choose all %s at once."
msgstr "Çlïçk tö çhöösé äll %s ät önçé. Ⱡ'σяєм ι#" msgstr "Çlïçk tö çhöösé äll %s ät önçé. Ⱡ'σяєм ι#"
...@@ -650,12 +639,10 @@ msgid "Remove" ...@@ -650,12 +639,10 @@ msgid "Remove"
msgstr "Rémövé Ⱡ'σяєм ιρѕ#" msgstr "Rémövé Ⱡ'σяєм ιρѕ#"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "Chosen %s" msgid "Chosen %s"
msgstr "Çhösén %s #" msgstr "Çhösén %s #"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "" msgid ""
"This is the list of chosen %s. You may remove some by selecting them in the " "This is the list of chosen %s. You may remove some by selecting them in the "
"box below and then clicking the \"Remove\" arrow between the two boxes." "box below and then clicking the \"Remove\" arrow between the two boxes."
...@@ -669,7 +656,6 @@ msgid "Remove all" ...@@ -669,7 +656,6 @@ msgid "Remove all"
msgstr "Rémövé äll Ⱡ#" msgstr "Rémövé äll Ⱡ#"
#: lms/static/admin/js/SelectFilter2.js #: lms/static/admin/js/SelectFilter2.js
#, c-format
msgid "Click to remove all chosen %s at once." msgid "Click to remove all chosen %s at once."
msgstr "Çlïçk tö rémövé äll çhösén %s ät önçé. Ⱡ'σяєм ιρѕ#" msgstr "Çlïçk tö rémövé äll çhösén %s ät önçé. Ⱡ'σяєм ιρѕ#"
...@@ -1271,7 +1257,6 @@ msgid "Studio's having trouble saving your work" ...@@ -1271,7 +1257,6 @@ msgid "Studio's having trouble saving your work"
msgstr "Stüdïö's hävïng tröüßlé sävïng ýöür wörk Ⱡ'σяєм ιρѕυ#" msgstr "Stüdïö's hävïng tröüßlé sävïng ýöür wörk Ⱡ'σяєм ιρѕυ#"
#: cms/static/coffee/src/views/module_edit.js #: cms/static/coffee/src/views/module_edit.js
#, c-format
msgid "<em>Editing:</em> %s" msgid "<em>Editing:</em> %s"
msgstr "<em>Édïtïng:</em> %s Ⱡ'σ#" msgstr "<em>Édïtïng:</em> %s Ⱡ'σ#"
......
...@@ -79,25 +79,31 @@ def main(): ...@@ -79,25 +79,31 @@ def main():
source_msgs_dir.joinpath('djangojs-partial.po') source_msgs_dir.joinpath('djangojs-partial.po')
) )
files_to_clean = set()
# Extract strings from third-party applications. # Extract strings from third-party applications.
for app_name in CONFIGURATION.third_party: for app_name in CONFIGURATION.third_party:
# Import the app to find out where it is. Then use pybabel to extract # Import the app to find out where it is. Then use pybabel to extract
# from that directory. # from that directory.
app_module = importlib.import_module(app_name) app_module = importlib.import_module(app_name)
app_dir = path(app_module.__file__).dirname().dirname() app_dir = path(app_module.__file__).dirname().dirname()
output_file = source_msgs_dir / (app_name + ".po")
files_to_clean.add(output_file)
babel_cmd = 'pybabel extract -F {config} -c "Translators:" {app} -o {output}' babel_cmd = 'pybabel extract -F {config} -c "Translators:" {app} -o {output}'
babel_cmd = babel_cmd.format( babel_cmd = babel_cmd.format(
config=LOCALE_DIR / 'babel_third_party.cfg', config=LOCALE_DIR / 'babel_third_party.cfg',
app=app_name, app=app_name,
output=source_msgs_dir / (app_name + ".po"), output=output_file,
) )
execute(babel_cmd, working_directory=app_dir) execute(babel_cmd, working_directory=app_dir)
# Segment the generated files. # Segment the generated files.
segmented_files = segment_pofiles("en") segmented_files = segment_pofiles("en")
files_to_clean.update(segmented_files)
# Finish each file. # Finish each file.
for filename in segmented_files: for filename in files_to_clean:
LOG.info('Cleaning %s' % filename) LOG.info('Cleaning %s' % filename)
po = pofile(source_msgs_dir.joinpath(filename)) po = pofile(source_msgs_dir.joinpath(filename))
# replace default headers with edX headers # replace default headers with edX headers
......
...@@ -53,8 +53,7 @@ def merge(locale, target='django.po', sources=('django-partial.po',), fail_if_mi ...@@ -53,8 +53,7 @@ def merge(locale, target='django.po', sources=('django-partial.po',), fail_if_mi
# clean up redunancies in the metadata # clean up redunancies in the metadata
merged_filename = locale_directory.joinpath('merged.po') merged_filename = locale_directory.joinpath('merged.po')
clean_metadata(merged_filename) clean_pofile(merged_filename)
clean_line_numbers(merged_filename)
# rename merged.po -> django.po (default) # rename merged.po -> django.po (default)
target_filename = locale_directory.joinpath(target) target_filename = locale_directory.joinpath(target)
...@@ -69,25 +68,32 @@ def merge_files(locale, fail_if_missing=True): ...@@ -69,25 +68,32 @@ def merge_files(locale, fail_if_missing=True):
merge(locale, target, sources, fail_if_missing) merge(locale, target, sources, fail_if_missing)
def clean_metadata(file): def clean_pofile(file):
""" """
Clean up redundancies in the metadata caused by merging. Clean various aspect of a .po file.
Fixes:
- Removes the ,fuzzy flag on metadata.
- Removes occurrence line numbers so that the generated files don't
generate a lot of line noise when they're committed.
- Removes any flags ending with "-format". Mac gettext seems to add
these flags, Linux does not, and we don't seem to need them. By
removing them, we reduce the unimportant differences that clutter
diffs as different developers work on the files.
""" """
# Reading in the .po file and saving it again fixes redundancies. # Reading in the .po file and saving it again fixes redundancies.
pomsgs = pofile(file) pomsgs = pofile(file)
# The msgcat tool marks the metadata as fuzzy, but it's ok as it is. # The msgcat tool marks the metadata as fuzzy, but it's ok as it is.
pomsgs.metadata_is_fuzzy = False pomsgs.metadata_is_fuzzy = False
pomsgs.save()
def clean_line_numbers(file):
"""
Remove occurrence line numbers so that the generated files don't generate a lot of
line noise when they're committed.
"""
pomsgs = pofile(file)
for entry in pomsgs: for entry in pomsgs:
# Remove line numbers
entry.occurrences = [(filename, None) for (filename, lineno) in entry.occurrences] entry.occurrences = [(filename, None) for (filename, lineno) in entry.occurrences]
# Remove -format flags
entry.flags = [f for f in entry.flags if not f.endswith("-format")]
pomsgs.save() pomsgs.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment