98
99
class TestInstall(tests.TestCase):
102
super(TestInstall, self).setUp()
103
# Restore a proper env to test translation installation
104
self.overrideAttr(i18n, '_translations', None)
100
106
def test_custom_languages(self):
101
self.addCleanup(i18n.install)
102
107
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)
104
113
def test_no_env_variables(self):
105
self.addCleanup(i18n.install)
106
114
self.overrideEnv('LANGUAGE', None)
107
115
self.overrideEnv('LC_ALL', None)
108
116
self.overrideEnv('LC_MESSAGES', None)
109
117
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)
112
132
class TestTranslate(tests.TestCaseWithTransport):
119
139
"""do errors get translated?"""
121
141
tree = self.make_branch_and_tree('.')
122
self.overrideAttr(i18n, '_translations', ZzzTranslations())
124
143
workingtree.WorkingTree.open('./foo')
125
144
except errors.NotBranchError,e:
130
149
def test_topic_help_translation(self):
131
150
"""does topic help get translated?"""
132
151
from bzrlib import help
134
self.overrideAttr(i18n, '_translations', ZzzTranslations())
135
152
from StringIO import StringIO
137
154
help.help("authentication", out)
138
155
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"))