Skip to content

Commit

Permalink
Try clearing gettext cache with bindtextdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-easterbrook committed Dec 27, 2023
1 parent cbbba72 commit 91a993a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ def test_localisation(self):
str_en = 'Failed to read input data'
str_de = 'Die Eingabedaten konnten nicht gelesen werden.'
old_locale = locale.setlocale(locale.LC_MESSAGES, None)
locale_dir = locale.bindtextdomain('exiv2', None)
# clear current locale
locale.setlocale(locale.LC_MESSAGES, 'C')
## self.assertEqual(exiv2.exvGettext(str_en), str_en)
self.assertEqual(exiv2.exvGettext(str_en), str_en)
# set German locale
for name in ('de_DE.utf8', 'de_DE.UTF-8', 'de_DE', 'German'):
try:
Expand All @@ -132,6 +133,8 @@ def test_localisation(self):
return
if locale.getlocale() == (None, None):
self.skipTest("set locale had no effect")
# call bindtextdomain to clear cache
locale.bindtextdomain('exiv2', locale_dir)
self.assertEqual(exiv2.exvGettext(str_en), str_de)
locale.setlocale(locale.LC_MESSAGES, old_locale)

Expand Down

0 comments on commit 91a993a

Please sign in to comment.