Make i18n a real package.
This commit is contained in:
0
i18n/__init__.py
Normal file
0
i18n/__init__.py
Normal file
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os, subprocess, logging
|
||||
|
||||
from config import CONFIGURATION, BASE_DIR
|
||||
from i18n.config import BASE_DIR
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>',
|
||||
u'Language-Team': u'LANGUAGE <LL@li.org>',
|
||||
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 <translation_team@edx.org>',
|
||||
}
|
||||
|
||||
# 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 <EMAIL@ADDRESS>',
|
||||
# u'Language-Team': u'LANGUAGE <LL@li.org>',
|
||||
# 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 <translation_team@edx.org>',
|
||||
}
|
||||
po.metadata.update(fixes)
|
||||
|
||||
def strip_key_strings(po):
|
||||
|
||||
@@ -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__)
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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):
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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/'
|
||||
|
||||
Reference in New Issue
Block a user