forked from git-cola/git-cola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
i18n_test.py
58 lines (47 loc) · 1.67 KB
/
i18n_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from __future__ import absolute_import, division, unicode_literals
import unittest
from cola import i18n
from cola.i18n import N_
from cola.compat import unichr
class ColaI18nTestCase(unittest.TestCase):
"""Test cases for the ColaApplication class"""
def tearDown(self):
i18n.uninstall()
def test_translates_noun(self):
"""Test that strings with @@noun are translated
"""
i18n.install('ja_JP')
expect = (unichr(0x30b3) + unichr(0x30df) +
unichr(0x30c3) + unichr(0x30c8))
actual = N_('Commit@@verb')
self.assertEqual(expect, actual)
def test_translates_verb(self):
"""Test that strings with @@verb are translated
"""
i18n.install('de_DE')
expect = 'Version aufnehmen'
actual = N_('Commit@@verb')
self.assertEqual(expect, actual)
def test_translates_english_noun(self):
"""Test that English strings with @@noun are properly handled
"""
i18n.install('en_US.UTF-8')
expect = 'Commit'
actual = N_('Commit@@noun')
self.assertEqual(expect, actual)
def test_translates_english_verb(self):
"""Test that English strings with @@verb are properly handled
"""
i18n.install('en_US.UTF-8')
expect = 'Commit'
actual = N_('Commit@@verb')
self.assertEqual(expect, actual)
def test_translates_random_english(self):
"""Test that random English strings are passed through as-is
"""
i18n.install('en_US.UTF-8')
expect = 'Random'
actual = N_('Random')
self.assertEqual(expect, actual)
if __name__ == '__main__':
unittest.main()