1 """Tests for the i18n translation module"""
2 from __future__
import absolute_import
, division
, print_function
, unicode_literals
8 from cola
.i18n
import N_
9 from cola
.compat
import uchr
12 @pytest.fixture(autouse
=True)
14 """Perform cleanup/teardown of the i18n module"""
19 def test_translates_noun():
20 """Test that strings with @@noun are translated"""
22 expect
= uchr(0x30B3) + uchr(0x30DF) + uchr(0x30C3) + uchr(0x30C8)
23 actual
= N_('Commit@@verb')
24 assert expect
== actual
27 def test_translates_verb():
28 """Test that strings with @@verb are translated"""
30 expect
= 'Commit aufnehmen'
31 actual
= N_('Commit@@verb')
32 assert expect
== actual
35 def test_translates_english_noun():
36 """Test that English strings with @@noun are properly handled"""
37 i18n
.install('en_US.UTF-8')
39 actual
= N_('Commit@@noun')
40 assert expect
== actual
43 def test_translates_english_verb():
44 """Test that English strings with @@verb are properly handled"""
45 i18n
.install('en_US.UTF-8')
47 actual
= N_('Commit@@verb')
48 assert expect
== actual
51 def test_translates_random_english():
52 """Test that random English strings are passed through as-is"""
53 i18n
.install('en_US.UTF-8')
56 assert expect
== actual
59 def test_translate_push_pull_french():
63 assert expect
== actual
67 assert expect
== actual
70 def test_get_filename_for_locale():
71 """Ensure that the appropriate .po files are found"""
72 actual
= i18n
.get_filename_for_locale('does_not_exist')
75 actual
= i18n
.get_filename_for_locale('id_ID')
76 assert os
.path
.basename(actual
) == 'id_ID.po'
78 actual
= i18n
.get_filename_for_locale('ja_JP')
79 assert os
.path
.basename(actual
) == 'ja.po'