Skip to content

Commit

Permalink
Merge pull request #22 from edx/ned/loc-89
Browse files Browse the repository at this point in the history
LOC-89 RTL dummy language translates %s
  • Loading branch information
nedbat committed Aug 19, 2015
2 parents 8c977db + 47b6502 commit e7ca704
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions i18n/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Converter(object):
(<[^>]+>) | # <tag>
({[^}]+}) | # {tag}
(%\([\w]+\)\w) | # %(tag)s
(%[sdrxf]) | # %s
(&\w+;) | # &entity;
(&\#\d+;) | # &#1234;
(&\#x[0-9a-f]+;) # &#xABCD;
Expand Down
10 changes: 8 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
coveralls
pylint
ddt
django
mock
nose
path.py
pep8
polib
pylint
pytz
rednose
django
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='i18n_tools',
version='0.1',
version='0.1.3',
description='edX i18n tools',
packages=[
'i18n',
Expand Down
3 changes: 3 additions & 0 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class TestConverter(TestCase):
# .format-style tags
('The {0} barn is {1!r}.',
'THE {0} BARN IS {1!r}.'),
# Not-as-useful Python tags
('A string (%s) and a number (%d)',
'A STRING (%s) AND A NUMBER (%d)'),
# HTML entities
('<b>&copy; 2013 edX, &#xa0;</b>',
'<b>&copy; 2013 EDX, &#xa0;</b>'),
Expand Down
33 changes: 32 additions & 1 deletion tests/test_dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ def assertUnicodeEquals(self, str1, str2):
(u"don't convert %(name)s tags on %(date)s",
u"dön't çönvért %(name)s tägs ön %(date)s Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢#"),
(u"don't convert %s tags on %s",
u"dön't çönvért %s tägs ön %s Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢#"),
)
def test_dummy(self, data):
"""
Tests with a dummy converter (adds spurious accents to strings).
Assert that embedded HTML and python tags are not converted.
Assert that embedded HTML and Python tags are not converted.
"""
source, expected = data
result = self.converter.convert(source)
Expand All @@ -73,3 +76,31 @@ def test_plural(self):
result = entry.msgstr_plural
self.assertUnicodeEquals(result['0'], expected_s)
self.assertUnicodeEquals(result['1'], expected_p)

@ddt.data(
(u"sign in",
u"سهلر هر"),
(u"my name is Bond",
u"وغ رشوث هس زخري"),
(u"hello my name is Bond, James Bond",
u"اثممخ وغ رشوث هس زخري, تشوثس زخري"),
(u"don't convert <a href='href'>tag ids</a>",
u"يخر'ف ذخردثقف <a href='href'>فشل هيس</a>"),
(u"don't convert %(name)s tags on %(date)s",
u"يخر'ف ذخردثقف %(name)s فشلس خر %(date)s"),
(u"don't convert %s tags on %s",
u"يخر'ف ذخردثقف %s فشلس خر %s"),
)
def test_dummy_arabic(self, data):
"""
Tests with a dummy Arabic converter for RTL.
Assert that embedded HTML and Python tags are not converted.
"""
source, expected = data
result = dummy.ArabicDummy().convert(source)
self.assertUnicodeEquals(result, expected)

0 comments on commit e7ca704

Please sign in to comment.