Skip to content

Commit

Permalink
Merge pull request #3467 from aronasorman/let_there_be_i18n
Browse files Browse the repository at this point in the history
More i18n fixes
  • Loading branch information
aronasorman committed Apr 2, 2015
2 parents ce1e8fa + 029830e commit 73d5ad8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion data/khan/channel_data.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"channel_name": "KA Lite",
"head_line": "A free world-class education for anyone anywhere.",
"tag_line": "KA Lite is a lightweight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection.",
"tag_line": "KA Lite is a light-weight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection.",
"channel_license": "CC-BY-NC-SA",
"footer_text": "Videos © 2015 Khan Academy (Creative Commons) // Exercises © 2015 Khan Academy"
}
2 changes: 1 addition & 1 deletion kalite/distributed/static/perseus/ke/local-only/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
str = str.messages[0];
}

return interpolateStringToArray(str, options).join("");
return interpolateStringToArray(gettext(str), options).join("");
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

{% trans "KA Lite" %}
{% trans "A free world-class education for anyone anywhere." %}
{% trans "KA Lite is a lightweight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection." %}
{% trans "Videos and Exercises © 2014 Khan Academy" %}
{% trans "KA Lite is a light-weight web server for viewing and interacting with core Khan Academy content (videos and exercises) without needing an Internet connection." %}
{% trans "Videos and Exercises © 2014 Khan Academy" %}
5 changes: 2 additions & 3 deletions kalite/topic_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_exercise_cache(force=False, language=settings.LANGUAGE_CODE):
exercise_template = os.path.join(exercise_lang, exercise_file)


with i18n.translate_block(exercise_lang):
with i18n.translate_block(language):
exercise["available"] = available
exercise["lang"] = exercise_lang
exercise["template"] = exercise_template
Expand Down Expand Up @@ -534,8 +534,7 @@ def smart_translate_item_data(item_data):
elif isinstance(field_data, list):
item_data[field] = map(smart_translate_item_data, field_data)


return item_data
return item_data



Expand Down
12 changes: 12 additions & 0 deletions kalite/topic_tools/tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ class SmartTranslateItemDataTests(KALiteTestCase):
def tearDown(self):
ugettext_dummy.reset_mock()

def test_list_of_dicts(self):
# test_data = {"hints": [{"content": TRANS_STRING, "images": {}, "widgets": {}}]}
# expected_data = {"hints": [{"content": DUMMY_STRING, "images": {}, "widgets": {}}]}
self.maxDiff = None
test_data = {'question': {'content': TRANS_STRING, 'images': {'/content/khan/f24b1c8daf0d1b16bf2dc391393b655e72190290.png': {'width': 450, 'height': 81}}, 'widgets': {'radio 1': {'version': {'major': 0, 'minor': 0}, 'type': 'radio', 'graded': True, 'options': {'onePerLine': True, 'noneOfTheAbove': False, 'choices': [], 'displayCount': None, 'multipleSelect': False, 'randomize': True}}}}, 'answerArea': {'calculator': False, 'type': 'multiple', 'options': {'content': '', 'images': {}, 'widgets': {}}}, 'itemDataVersion': {'major': 0, 'minor': 1}, 'hints': [{'content': TRANS_STRING, 'images': {}, 'widgets': {}}]}
expected_data = {'question': {'content': DUMMY_STRING, 'images': {'/content/khan/f24b1c8daf0d1b16bf2dc391393b655e72190290.png': {'width': 450, 'height': 81}}, 'widgets': {'radio 1': {'version': {'major': 0, 'minor': 0}, 'type': 'radio', 'graded': True, 'options': {'onePerLine': True, 'noneOfTheAbove': False, 'choices': [], 'displayCount': None, 'multipleSelect': False, 'randomize': True}}}}, 'answerArea': {'calculator': False, 'type': 'multiple', 'options': {'content': '', 'images': {}, 'widgets': {}}}, 'itemDataVersion': {'major': 0, 'minor': 1}, 'hints': [{'content': DUMMY_STRING, 'images': {}, 'widgets': {}}]}

result = mod.smart_translate_item_data(test_data)
# ugettext_dummy.assert_called_once_with(TRANS_STRING)

self.assertEqual(result, expected_data)

def test_list_of_lists(self):
test_data = [[TRANS_STRING]]
expected_data = [[DUMMY_STRING]]
Expand Down

0 comments on commit 73d5ad8

Please sign in to comment.