diff --git a/i18n/__init__.py b/i18n/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/i18n/dummy.py b/i18n/dummy.py index 2e6c073db0..ff68c68089 100644 --- a/i18n/dummy.py +++ b/i18n/dummy.py @@ -28,7 +28,7 @@ Example use:: """ -from converter import Converter +from i18n.converter import Converter # Substitute plain characters with accented lookalikes. # http://tlt.its.psu.edu/suggestions/international/web/codehtml.html#accent diff --git a/i18n/execute.py b/i18n/execute.py index cab07279a3..28222177c4 100644 --- a/i18n/execute.py +++ b/i18n/execute.py @@ -1,6 +1,6 @@ import os, subprocess, logging -from config import CONFIGURATION, BASE_DIR +from i18n.config import BASE_DIR LOG = logging.getLogger(__name__) diff --git a/i18n/extract.py b/i18n/extract.py index 5cd617b463..1356d995c7 100755 --- a/i18n/extract.py +++ b/i18n/extract.py @@ -19,8 +19,9 @@ import os, sys, logging from datetime import datetime from polib import pofile -from config import BASE_DIR, LOCALE_DIR, CONFIGURATION -from execute import execute, create_dir_if_necessary, remove_file +from i18n.config import BASE_DIR, LOCALE_DIR, CONFIGURATION +from i18n.execute import execute, create_dir_if_necessary, remove_file + # BABEL_CONFIG contains declarations for Babel to extract strings from mako template files # Use relpath to reduce noise in logs @@ -79,18 +80,18 @@ def main(): strip_key_strings(po) po.save() -# By default, django-admin.py makemessages creates this header: -""" -SOME DESCRIPTIVE TITLE. -Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -This file is distributed under the same license as the PACKAGE package. -FIRST AUTHOR , YEAR. -""" - def fix_header(po): """ Replace default headers with edX headers """ + + # By default, django-admin.py makemessages creates this header: + # + # SOME DESCRIPTIVE TITLE. + # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER + # This file is distributed under the same license as the PACKAGE package. + # FIRST AUTHOR , YEAR. + po.metadata_is_fuzzy = [] # remove [u'fuzzy'] header = po.header fixes = ( @@ -110,31 +111,32 @@ def fix_header(po): header = header.replace(src, dest) po.header = header -# By default, django-admin.py makemessages creates this metadata: -""" -{u'PO-Revision-Date': u'YEAR-MO-DA HO:MI+ZONE', - u'Language': u'', - u'Content-Transfer-Encoding': u'8bit', - u'Project-Id-Version': u'PACKAGE VERSION', - u'Report-Msgid-Bugs-To': u'', - u'Last-Translator': u'FULL NAME ', - u'Language-Team': u'LANGUAGE ', - u'POT-Creation-Date': u'2013-04-25 14:14-0400', - u'Content-Type': u'text/plain; charset=UTF-8', - u'MIME-Version': u'1.0'} -""" - def fix_metadata(po): """ Replace default metadata with edX metadata """ - fixes = {'PO-Revision-Date': datetime.utcnow(), - 'Report-Msgid-Bugs-To': 'translation_team@edx.org', - 'Project-Id-Version': '0.1a', - 'Language' : 'en', - 'Last-Translator' : '', - 'Language-Team': 'translation team ', - } + + # By default, django-admin.py makemessages creates this metadata: + # + # {u'PO-Revision-Date': u'YEAR-MO-DA HO:MI+ZONE', + # u'Language': u'', + # u'Content-Transfer-Encoding': u'8bit', + # u'Project-Id-Version': u'PACKAGE VERSION', + # u'Report-Msgid-Bugs-To': u'', + # u'Last-Translator': u'FULL NAME ', + # u'Language-Team': u'LANGUAGE ', + # u'POT-Creation-Date': u'2013-04-25 14:14-0400', + # u'Content-Type': u'text/plain; charset=UTF-8', + # u'MIME-Version': u'1.0'} + + fixes = { + 'PO-Revision-Date': datetime.utcnow(), + 'Report-Msgid-Bugs-To': 'translation_team@edx.org', + 'Project-Id-Version': '0.1a', + 'Language' : 'en', + 'Last-Translator' : '', + 'Language-Team': 'translation team ', + } po.metadata.update(fixes) def strip_key_strings(po): diff --git a/i18n/generate.py b/i18n/generate.py index 8afa93c655..a851d9217e 100755 --- a/i18n/generate.py +++ b/i18n/generate.py @@ -16,8 +16,8 @@ languages to generate. import os, sys, logging from polib import pofile -from config import BASE_DIR, CONFIGURATION -from execute import execute +from i18n.config import BASE_DIR, CONFIGURATION +from i18n.execute import execute LOG = logging.getLogger(__name__) diff --git a/i18n/make_dummy.py b/i18n/make_dummy.py index 11021d4036..58a874f5fb 100755 --- a/i18n/make_dummy.py +++ b/i18n/make_dummy.py @@ -24,9 +24,10 @@ import os, sys import polib -from dummy import Dummy -from config import CONFIGURATION -from execute import create_dir_if_necessary + +from i18n.dummy import Dummy +from i18n.config import CONFIGURATION +from i18n.execute import create_dir_if_necessary def main(file, locale): diff --git a/i18n/tests/test_config.py b/i18n/tests/test_config.py index 762b42b837..51b2669fcf 100644 --- a/i18n/tests/test_config.py +++ b/i18n/tests/test_config.py @@ -1,7 +1,7 @@ import os from unittest import TestCase -from config import Configuration, LOCALE_DIR, CONFIGURATION +from i18n.config import Configuration, LOCALE_DIR, CONFIGURATION class TestConfiguration(TestCase): """ diff --git a/i18n/tests/test_converter.py b/i18n/tests/test_converter.py index e893f7c258..6b9c83b2ca 100644 --- a/i18n/tests/test_converter.py +++ b/i18n/tests/test_converter.py @@ -1,10 +1,10 @@ """Tests of i18n/converter.py""" -import os from unittest import TestCase + import ddt -import converter +from i18n import converter class UpcaseConverter(converter.Converter): """ diff --git a/i18n/tests/test_dummy.py b/i18n/tests/test_dummy.py index cd51c59743..a641f146b1 100644 --- a/i18n/tests/test_dummy.py +++ b/i18n/tests/test_dummy.py @@ -1,13 +1,12 @@ # -*- coding: utf-8 -*- """Tests of i18n/dummy.py""" -import os, string, random from unittest import TestCase import ddt from polib import POEntry -import dummy +from i18n import dummy @ddt.ddt diff --git a/i18n/tests/test_extract.py b/i18n/tests/test_extract.py index 3ef87a3736..bda0abef05 100644 --- a/i18n/tests/test_extract.py +++ b/i18n/tests/test_extract.py @@ -1,12 +1,13 @@ -import os -import polib -from unittest import TestCase -from nose.plugins.skip import SkipTest from datetime import datetime, timedelta +import os +from unittest import TestCase + +from nose.plugins.skip import SkipTest +import polib from pytz import UTC -import extract -from config import CONFIGURATION +from i18n import extract +from i18n.config import CONFIGURATION # Make sure setup runs only once SETUP_HAS_RUN = False diff --git a/i18n/tests/test_generate.py b/i18n/tests/test_generate.py index f18dff0320..8dcc5edcb8 100644 --- a/i18n/tests/test_generate.py +++ b/i18n/tests/test_generate.py @@ -1,14 +1,15 @@ +from datetime import datetime, timedelta import os import string import random import re -from polib import pofile from unittest import TestCase -from datetime import datetime, timedelta + +from polib import pofile from pytz import UTC -import generate -from config import CONFIGURATION +from i18n import generate +from i18n.config import CONFIGURATION class TestGenerate(TestCase): diff --git a/i18n/tests/test_validate.py b/i18n/tests/test_validate.py index a7c400da0f..d2364916fd 100644 --- a/i18n/tests/test_validate.py +++ b/i18n/tests/test_validate.py @@ -8,9 +8,9 @@ import textwrap import polib -from config import LOCALE_DIR -from execute import call -from converter import Converter +from i18n.config import LOCALE_DIR +from i18n.execute import call +from i18n.converter import Converter def test_po_files(root=LOCALE_DIR): diff --git a/i18n/transifex.py b/i18n/transifex.py index 8653c901f9..8c74d9b2f9 100755 --- a/i18n/transifex.py +++ b/i18n/transifex.py @@ -1,10 +1,11 @@ #!/usr/bin/env python -import os, sys +import sys from polib import pofile -from config import CONFIGURATION -from extract import SOURCE_WARN -from execute import execute + +from i18n.config import CONFIGURATION +from i18n.extract import SOURCE_WARN +from i18n.execute import execute TRANSIFEX_HEADER = 'Translations in this file have been downloaded from %s' TRANSIFEX_URL = 'https://www.transifex.com/projects/p/edx-studio/'