Skip to content

Commit 62b87fc

Browse files
committed
Fixed locale test in the presence of LANGUAGE
According to GNU documents, the priority order of language variables is LANGUAGE, LC_ALL, LC_*, LANG. Therefore, if LANGUAGE is set, it overrides the LC_ALL setting from the test. An empty value is ignored, and setting it to empty is easier to deal with than just deleting the variable. Also fixed the Google translate fail esperanto grammar. Fixes bug 1235058 Change-Id: Ic97b90dfc21997e19cc473250794a9b3c526beb5
1 parent 1508534 commit 62b87fc

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

test/unit/locale/eo.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
msgid "test message"
2-
msgstr "testo mesaĝon"
2+
msgstr "prova mesaĝo"

test/unit/locale/messages.mo

-1 Bytes
Binary file not shown.

test/unit/locale/test_locale.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,29 @@ def check_output(*popenargs, **kwargs):
3131
class TestTranslations(unittest.TestCase):
3232

3333
def setUp(self):
34-
self.la = os.environ.get('LC_ALL')
35-
self.sl = os.environ.get('SWIFT_LOCALEDIR')
34+
self.orig_env = {}
35+
for var in 'LC_ALL', 'SWIFT_LOCALEDIR', 'LANGUAGE':
36+
self.orig_env[var] = os.environ.get(var)
3637
os.environ['LC_ALL'] = 'eo'
3738
os.environ['SWIFT_LOCALEDIR'] = os.path.dirname(__file__)
39+
os.environ['LANGUAGE'] = ''
3840
self.orig_stop = threading._DummyThread._Thread__stop
3941
# See http://stackoverflow.com/questions/13193278/\
4042
# understand-python-threading-bug
4143
threading._DummyThread._Thread__stop = lambda x: 42
4244

4345
def tearDown(self):
44-
if self.la is not None:
45-
os.environ['LC_ALL'] = self.la
46-
else:
47-
del os.environ['LC_ALL']
48-
if self.sl is not None:
49-
os.environ['SWIFT_LOCALEDIR'] = self.sl
50-
else:
51-
del os.environ['SWIFT_LOCALEDIR']
46+
for var, val in self.orig_env.iteritems():
47+
if val is not None:
48+
os.environ[var] = val
49+
else:
50+
del os.environ[var]
5251
threading._DummyThread._Thread__stop = self.orig_stop
5352

5453
def test_translations(self):
5554
path = ':'.join(sys.path)
5655
translated_message = check_output(['python', __file__, path])
57-
self.assertEquals(translated_message, 'testo mesaĝon\n')
56+
self.assertEquals(translated_message, 'prova mesaĝo\n')
5857

5958

6059
if __name__ == "__main__":

0 commit comments

Comments
 (0)