test: Add translation extraction test
This commit is contained in:
parent
b1f3aa576c
commit
ba162425ac
2 changed files with 47 additions and 0 deletions
26
frappe/tests/test_translate.py
Normal file
26
frappe/tests/test_translate.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import frappe, unittest, os
|
||||
import frappe.translate
|
||||
|
||||
dirname = os.path.dirname(__file__)
|
||||
translation_string_file = os.path.join(dirname, 'translation_test_file.txt')
|
||||
|
||||
class TestTranslate(unittest.TestCase):
|
||||
def test_extract_message_from_file(self):
|
||||
data = frappe.translate.get_messages_from_file(translation_string_file)
|
||||
self.assertListEqual(data, expected_output)
|
||||
|
||||
expected_output = [
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', 'Warning: Unable to find {0} in any table related to {1}', 'This is some context', 2),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', 'Warning: Unable to find {0} in any table related to {1}', None, 4),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', "You don't have any messages yet.", None, 6),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', 'Submit', 'Some DocType', 8),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', 'Warning: Unable to find {0} in any table related to {1}', 'This is some context', 15),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', 'Submit', 'Some DocType', 17),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', "You don't have any messages yet.", None, 19),
|
||||
('apps/frappe/frappe/tests/translation_test_file.txt', "You don't have any messages yet.", None, 21)
|
||||
]
|
||||
|
||||
21
frappe/tests/translation_test_file.txt
Normal file
21
frappe/tests/translation_test_file.txt
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// JS syntax
|
||||
__("Warning: Unable to find {0} in any table related to {1}" , ['Key', 'DocType'], "This is some context")
|
||||
|
||||
__("Warning: Unable to find {0} in any table related to {1}" , ['Key', 'DocType'])
|
||||
|
||||
__("You don't have any messages yet.")
|
||||
|
||||
__('Submit' , null, "Some DocType")
|
||||
|
||||
// this is considered as invalid
|
||||
__('You don\'t have any messages yet.')
|
||||
|
||||
|
||||
// Python syntax
|
||||
_("Warning: Unable to find {0} in any table related to {1}", context="This is some context").format('Key', 'DocType')
|
||||
|
||||
_('Submit', context="Some DocType")
|
||||
|
||||
_("""You don't have any messages yet.""")
|
||||
|
||||
_('''You don't have any messages yet.''')
|
||||
Loading…
Add table
Reference in a new issue