Commit 4e879a4c by Calen Pennington

Add first pass at i18n automation tasks

parent d00314c8
...@@ -50,6 +50,7 @@ def merge(locale, target='django.po', sources=('django-partial.po',), fail_if_mi ...@@ -50,6 +50,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_metadata(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)
...@@ -75,6 +76,17 @@ def clean_metadata(file): ...@@ -75,6 +76,17 @@ def clean_metadata(file):
pomsgs.save() 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:
entry.occurrences = [(filename, None) for (filename, lineno) in entry.occurrences]
pomsgs.save()
def validate_files(dir, files_to_merge): def validate_files(dir, files_to_merge):
""" """
Asserts that the given files exist. Asserts that the given files exist.
......
...@@ -10,14 +10,14 @@ from i18n.execute import execute ...@@ -10,14 +10,14 @@ from i18n.execute import execute
TRANSIFEX_HEADER = 'Translations in this file have been downloaded from %s' TRANSIFEX_HEADER = 'Translations in this file have been downloaded from %s'
TRANSIFEX_URL = 'https://www.transifex.com/projects/p/edx-studio/' TRANSIFEX_URL = 'https://www.transifex.com/projects/p/edx-studio/'
def push(): def push():
execute('tx push -s') execute('tx push -s')
def pull(): def pull():
for locale in CONFIGURATION.locales: print "Pulling languages from transifex..."
if locale != CONFIGURATION.source_locale: execute('tx pull --mode=reviewed --all')
print "Pulling %s from transifex..." % locale
execute('tx pull -l %s' % locale)
clean_translated_locales() clean_translated_locales()
......
...@@ -13,7 +13,7 @@ namespace :i18n do ...@@ -13,7 +13,7 @@ namespace :i18n do
end end
desc "Simulate international translation by generating dummy strings corresponding to source strings." desc "Simulate international translation by generating dummy strings corresponding to source strings."
task :dummy do task :dummy => "i18n:extract" do
sh(File.join(REPO_ROOT, "i18n", "make_dummy.py")) sh(File.join(REPO_ROOT, "i18n", "make_dummy.py"))
end end
...@@ -63,4 +63,19 @@ namespace :i18n do ...@@ -63,4 +63,19 @@ namespace :i18n do
sh("#{pythonpath_prefix} nosetests #{test}") sh("#{pythonpath_prefix} nosetests #{test}")
end end
# Commands for automating the process of including translations in edx-platform.
# Will eventually be run by jenkins.
namespace :robot do
desc "Pull source strings, generate po and mo files, and validate"
task :pull => ["i18n:transifex:pull", "i18n:extract", "i18n:dummy", "i18n:generate"] do
sh('git clean -fdX conf/locale')
Rake::Task["i18n:test"].invoke
sh('git add conf/locale')
sh('git commit --message="Update translations (autogenerated message)" --edit')
end
desc "Extract new strings, and push to transifex"
task :push => ["i18n:extract", "i18n:transifex:push"]
end
end end
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