Skip to content

Commit

Permalink
Better use of gettext environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-easterbrook committed Dec 27, 2023
1 parent 78adc0d commit f8832ff
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
## along with this program. If not, see
## <http://www.gnu.org/licenses/>.

import importlib
import locale
import os
import random
Expand Down Expand Up @@ -122,10 +121,6 @@ def test_localisation(self):
for name in ('de_DE.utf8', 'de_DE.UTF-8', 'de_DE', 'German'):
try:
locale.setlocale(locale.LC_MESSAGES, name)
# on some OS, dgettext ignores locale and uses LANG
os.environ['LC_ALL'] = name
os.environ['LANG'] = name
os.environ['LANGUAGE'] = name
break
except locale.Error:
continue
Expand All @@ -134,8 +129,12 @@ def test_localisation(self):
return
if locale.getlocale() == (None, None):
self.skipTest("set locale had no effect")
# reimport exiv2 to clear cache
exiv2 = importlib.reload(exiv2)
if exiv2.exvGettext(str_en) == str_en:
# on some OS, gettext ignores locale and uses environment
os.environ['LANGUAGE'] = name
os.environ['LC_MESSAGES'] = name
os.environ['LANG'] = name
locale.setlocale(locale.LC_MESSAGES, '')
self.assertEqual(exiv2.exvGettext(str_en), str_de)
locale.setlocale(locale.LC_MESSAGES, old_locale)

Expand Down

0 comments on commit f8832ff

Please sign in to comment.