99
98
class TestInstall(tests.TestCase):
102
super(TestInstall, self).setUp()
103
# Restore a proper env to test translation installation
104
self.overrideAttr(i18n, '_translations', None)
106
100
def test_custom_languages(self):
101
self.addCleanup(i18n.install)
107
102
i18n.install('nl:fy')
108
# Whether we found a valid tranlsation or not doesn't matter, we got
109
# one and _translations is not None anymore.
110
self.assertIsInstance(i18n._translations,
111
i18n._gettext.NullTranslations)
113
104
def test_no_env_variables(self):
105
self.addCleanup(i18n.install)
114
106
self.overrideEnv('LANGUAGE', None)
115
107
self.overrideEnv('LC_ALL', None)
116
108
self.overrideEnv('LC_MESSAGES', None)
117
109
self.overrideEnv('LANG', None)
119
# Whether we found a valid tranlsation or not doesn't matter, we got
120
# one and _translations is not None anymore.
121
self.assertIsInstance(i18n._translations,
122
i18n._gettext.NullTranslations)
124
def test_disable_i18n(self):
127
# It's disabled, you can't install anything and we fallback to null
128
self.assertIsInstance(i18n._translations,
129
i18n._gettext.NullTranslations)
132
112
class TestTranslate(tests.TestCaseWithTransport):
139
119
"""do errors get translated?"""
141
121
tree = self.make_branch_and_tree('.')
122
self.overrideAttr(i18n, '_translations', ZzzTranslations())
143
124
workingtree.WorkingTree.open('./foo')
144
125
except errors.NotBranchError,e:
149
130
def test_topic_help_translation(self):
150
131
"""does topic help get translated?"""
151
132
from bzrlib import help
134
self.overrideAttr(i18n, '_translations', ZzzTranslations())
152
135
from StringIO import StringIO
154
137
help.help("authentication", out)
155
138
self.assertContainsRe(out.getvalue(), "zz\xe5{{Authentication Settings")
158
class LoadPluginTranslations(tests.TestCase):
160
def test_does_not_exist(self):
161
translation = i18n.load_plugin_translations("doesnotexist")
162
self.assertEquals("foo", translation.gettext("foo"))