Commit 6142c76c by Ned Batchelder

Merge pull request #12471 from edx/ned/release-translations

Support named-release translation files.
parents 49e66863 7aa1c1c2
...@@ -38,10 +38,10 @@ codekit-config.json ...@@ -38,10 +38,10 @@ codekit-config.json
!django.mo !django.mo
!djangojs.po !djangojs.po
!djangojs.mo !djangojs.mo
conf/locale/en/LC_MESSAGES/*.po
conf/locale/en/LC_MESSAGES/*.mo conf/locale/en/LC_MESSAGES/*.mo
conf/locale/fake*/LC_MESSAGES/*.po conf/locale/fake*/LC_MESSAGES/*.po
conf/locale/fake*/LC_MESSAGES/*.mo conf/locale/fake*/LC_MESSAGES/*.mo
# this was a mistake in i18n_tools, now fixed.
conf/locale/messages.mo conf/locale/messages.mo
### Testing artifacts ### Testing artifacts
......
...@@ -152,7 +152,6 @@ generate_merge: ...@@ -152,7 +152,6 @@ generate_merge:
- django-studio.po - django-studio.po
- mako.po - mako.po
- mako-studio.po - mako-studio.po
- messages.po
- wiki.po - wiki.po
djangojs.po: djangojs.po:
- djangojs-partial.po - djangojs-partial.po
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
# edX translation file
# Copyright (C) 2013 edX
# This file is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
#
msgid ""
msgstr ""
"Project-Id-Version: EdX Studio\n"
"Report-Msgid-Bugs-To: translation_team@edx.org\n"
"POT-Creation-Date: 2013-05-02 13:13-0400\n"
"PO-Revision-Date: 2013-05-02 13:27-0400\n"
"Last-Translator: \n"
"Language-Team: translation team <translation_team@edx.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: en\n"
# empty
msgid "This is a key string."
msgstr ""
""" """
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,68 @@ def i18n_robot_push(): ...@@ -228,3 +232,68 @@ 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()
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()
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 raises ValueError if .tx/config
doesn't have two resources.
"""
# 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:
raise ValueError("You need two release-* resources defined to use this command.")
else:
msg = "Strange Transifex config! Found these release-* resources:\n" + "\n".join(resources)
raise ValueError(msg)
"""
Tests for pavelib/i18n.py.
"""
import textwrap
import unittest
from mock import mock_open, patch
from paver.easy import task
import pavelib.i18n
from pavelib.paver_tests.utils import PaverTestCase
TX_CONFIG_SIMPLE = """\
[main]
host = https://www.transifex.com
[edx-platform.django-partial]
file_filter = conf/locale/<lang>/LC_MESSAGES/django-partial.po
source_file = conf/locale/en/LC_MESSAGES/django-partial.po
source_lang = en
type = PO
[edx-platform.django-studio]
file_filter = conf/locale/<lang>/LC_MESSAGES/django-studio.po
source_file = conf/locale/en/LC_MESSAGES/django-studio.po
source_lang = en
type = PO
"""
TX_CONFIG_RELEASE = TX_CONFIG_SIMPLE + """\
[edx-platform.release-zebrawood]
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-zebrawood-js]
file_filter = conf/locale/<lang>/LC_MESSAGES/djangojs.po
source_file = conf/locale/en/LC_MESSAGES/djangojs.po
source_lang = en
type = PO
"""
def mocked_i18n_open(*content):
"""
Helper decorator to mock open() in pavelib.i18n.
Arguments:
content (str): any number of strings, which are dedented, then
concatenated, and then returned as f.read() when pavelib.i18n opens
a file.
"""
read_data = "".join(textwrap.dedent(c) for c in content)
return patch.object(pavelib.i18n, 'open', create=True, new=mock_open(read_data=read_data))
@task
def do_nothing():
"""
Don't do anything, for replacing prerequisite tasks we want to skip.
"""
pass
class FindReleaseResourcesTest(unittest.TestCase):
"""
Tests of pavelib/i18n.py:find_release_resources.
"""
@mocked_i18n_open(TX_CONFIG_SIMPLE)
def test_no_resources(self):
errmsg = r"You need two release-\* resources defined to use this command."
with self.assertRaisesRegexp(ValueError, errmsg):
pavelib.i18n.find_release_resources()
@mocked_i18n_open(TX_CONFIG_SIMPLE, """\
[edx-platform.release-zebrawood]
file_filter = conf/locale/<lang>/LC_MESSAGES/django.po
source_file = conf/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
""")
def test_one_resource(self):
errmsg = r"Strange Transifex config! Found these release-\* resources:\nedx-platform.release-zebrawood"
with self.assertRaisesRegexp(ValueError, errmsg):
pavelib.i18n.find_release_resources()
@mocked_i18n_open(TX_CONFIG_RELEASE)
def test_good_resources(self):
self.assertEqual(
pavelib.i18n.find_release_resources(),
['edx-platform.release-zebrawood', 'edx-platform.release-zebrawood-js'],
)
class ReleasePushPullTest(PaverTestCase):
"""
Tests of i18n_release_push and i18n_release_pull.
"""
@mocked_i18n_open(TX_CONFIG_SIMPLE)
@patch.object(pavelib.i18n, 'i18n_generate', new=do_nothing)
def test_cant_push_nothing(self):
with self.assertRaises(SystemExit) as sysex:
pavelib.i18n.i18n_release_push()
# Check that we exited with a failure status code.
self.assertEqual(sysex.exception.args, (1,))
@mocked_i18n_open(TX_CONFIG_SIMPLE)
def test_cant_pull_nothing(self):
with self.assertRaises(SystemExit) as sysex:
pavelib.i18n.i18n_release_pull()
# Check that we exited with a failure status code.
self.assertEqual(sysex.exception.args, (1,))
@mocked_i18n_open(TX_CONFIG_RELEASE)
@patch.object(pavelib.i18n, 'i18n_generate', new=do_nothing)
@patch.object(pavelib.i18n, 'sh')
def test_can_push_release(self, mock_sh):
pavelib.i18n.i18n_release_push()
mock_sh.assert_called_once_with(
'i18n_tool transifex push edx-platform.release-zebrawood edx-platform.release-zebrawood-js'
)
@mocked_i18n_open(TX_CONFIG_RELEASE)
@patch.object(pavelib.i18n, 'sh')
def test_can_pull_release(self, mock_sh):
pavelib.i18n.i18n_release_pull()
mock_sh.assert_called_once_with(
'i18n_tool transifex pull edx-platform.release-zebrawood edx-platform.release-zebrawood-js'
)
...@@ -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