git-cola v1.9.0
[git-cola.git] / test / test_cola_i18n.py
blobd3c625253172194e9ba2394ccc3834d1386a0e4c
1 # -*- encoding: utf-8 -*-
2 import unittest
4 from PyQt4 import QtCore
6 from cola import i18n
7 from cola.i18n import N_
10 class ColaI18nTestCase(unittest.TestCase):
11 """Test cases for the ColaApplication class"""
13 def tearDown(self):
14 i18n.uninstall()
16 def test_translates_noun(self):
17 """Test that strings with @@noun are translated
18 """
19 i18n.install('ja_JP')
20 expect = (unichr(0x30b3) + unichr(0x30df) +
21 unichr(0x30c3) + unichr(0x30c8))
22 actual = N_('Commit@@verb')
23 self.assertEqual(expect, actual)
25 def test_translates_verb(self):
26 """Test that strings with @@verb are translated
27 """
28 i18n.install('de_DE')
29 expect = 'Version aufnehmen'
30 actual = N_('Commit@@verb')
31 self.assertEqual(expect, actual)
33 def test_translates_english_noun(self):
34 """Test that English strings with @@noun are properly handled
35 """
36 i18n.install('en_US.UTF-8')
37 expect = 'Commit'
38 actual = N_('Commit@@noun')
39 self.assertEqual(expect, actual)
41 def test_translates_english_verb(self):
42 """Test that English strings with @@verb are properly handled
43 """
44 i18n.install('en_US.UTF-8')
45 expect = 'Commit'
46 actual = N_('Commit@@verb')
47 self.assertEqual(expect, actual)
49 def test_translates_random_english(self):
50 """Test that random English strings are passed through as-is
51 """
52 i18n.install('en_US.UTF-8')
53 expect = 'Random'
54 actual = N_('Random')
55 self.assertEqual(expect, actual)
57 def test_guards_against_qstring(self):
58 """Test that random QString is passed through as-is
59 """
60 i18n.install('en_US.UTF-8')
61 expect = 'Random'
62 actual = i18n.gettext(QtCore.QString('Random'))
63 self.assertEqual(expect, actual)
66 if __name__ == '__main__':
67 unittest.main()