Commit f88181ac by Ned Batchelder

Add paver i18n_release_push and _pull commands

parent 437e61d6
""" """
Internationalization tasks Internationalization tasks
""" """
import re
import sys import sys
import subprocess import subprocess
from path import Path as path from path import Path as path
from paver.easy import task, cmdopts, needs, sh from paver.easy import task, cmdopts, needs, sh
from .utils.cmd import django_cmd from .utils.cmd import django_cmd
try: try:
...@@ -228,3 +232,75 @@ def i18n_robot_push(): ...@@ -228,3 +232,75 @@ def i18n_robot_push():
Extract new strings, and push to transifex Extract new strings, and push to transifex
""" """
pass pass
@task
@needs(
"pavelib.i18n.i18n_validate_transifex_config",
"pavelib.i18n.i18n_generate",
)
def i18n_release_push():
"""
Push release-specific resources to Transifex.
"""
resources = find_release_resources()
if resources is None:
return
sh("i18n_tool transifex push " + " ".join(resources))
@task
@needs(
"pavelib.i18n.i18n_validate_transifex_config",
)
def i18n_release_pull():
"""
Pull release-specific translations from Transifex.
"""
resources = find_release_resources()
if resources is None:
return
sh("i18n_tool transifex pull " + " ".join(resources))
def find_release_resources():
"""
Validate the .tx/config file for release files, returning the resource names.
For working with release files, the .tx/config file should have exactly
two resources defined named "release-*". Check that this is true. If
there's a problem, print messages about it.
Returns a list of resource names, or None if the file doesn't validate.
"""
# An entry in .tx/config for a release will look like this:
#
# [edx-platform.release-dogwood]
# file_filter = conf/locale/<lang>/LC_MESSAGES/django.po
# source_file = conf/locale/en/LC_MESSAGES/django.po
# source_lang = en
# type = PO
#
# [edx-platform.release-dogwood-js]
# file_filter = conf/locale/<lang>/LC_MESSAGES/djangojs.po
# source_file = conf/locale/en/LC_MESSAGES/djangojs.po
# source_lang = en
# type = PO
rx_release = r"^\[([\w-]+\.release-[\w-]+)\]$"
with open(".tx/config") as tx_config:
resources = re.findall(rx_release, tx_config.read(), re.MULTILINE)
if len(resources) == 2:
return resources
if len(resources) == 0:
print "You need two release-* resources defined to use this command."
else:
print "Strange Transifex config! Found these release-* resources:"
print "\n".join(resources)
return None
...@@ -78,7 +78,7 @@ git+https://github.com/edx/XBlock.git@xblock-0.4.10#egg=XBlock==0.4.10 ...@@ -78,7 +78,7 @@ git+https://github.com/edx/XBlock.git@xblock-0.4.10#egg=XBlock==0.4.10
git+https://github.com/edx/edx-ora2.git@1.1.4#egg=ora2==1.1.4 git+https://github.com/edx/edx-ora2.git@1.1.4#egg=ora2==1.1.4
-e git+https://github.com/edx/edx-submissions.git@1.1.0#egg=edx-submissions==1.1.0 -e git+https://github.com/edx/edx-submissions.git@1.1.0#egg=edx-submissions==1.1.0
git+https://github.com/edx/ease.git@release-2015-07-14#egg=ease==0.1.3 git+https://github.com/edx/ease.git@release-2015-07-14#egg=ease==0.1.3
git+https://github.com/edx/i18n-tools.git@v0.2#egg=i18n-tools==v0.2 git+https://github.com/edx/i18n-tools.git@v0.3#egg=i18n-tools==v0.3
git+https://github.com/edx/edx-val.git@0.0.9#egg=edxval==0.0.9 git+https://github.com/edx/edx-val.git@0.0.9#egg=edxval==0.0.9
-e git+https://github.com/pmitros/RecommenderXBlock.git@518234bc354edbfc2651b9e534ddb54f96080779#egg=recommender-xblock -e git+https://github.com/pmitros/RecommenderXBlock.git@518234bc354edbfc2651b9e534ddb54f96080779#egg=recommender-xblock
git+https://github.com/solashirai/crowdsourcehinter.git@518605f0a95190949fe77bd39158450639e2e1dc#egg=crowdsourcehinter-xblock==0.1 git+https://github.com/solashirai/crowdsourcehinter.git@518605f0a95190949fe77bd39158450639e2e1dc#egg=crowdsourcehinter-xblock==0.1
......
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