Who even uses this "Windows" thing...?

This commit is contained in:
Stan Ulbrych 2025-06-19 15:37:57 +01:00
parent c40039fa3d
commit d75292d33e
No known key found for this signature in database
GPG key ID: B8E58DBDB2A1A0B8
2 changed files with 7 additions and 5 deletions

View file

@ -493,7 +493,7 @@ def find(domain, localedir=None, languages=None, all=False):
languages = []
if val := os.environ.get('LANGUAGE'):
languages = val.split(':')
elif loc := locale.setlocale(locale.LC_MESSAGES):
elif os.name == 'posix' and (loc := locale.setlocale(locale.LC_MESSAGES)):
languages = loc.split(':')
else:
for envar in ('LC_ALL', 'LC_MESSAGES', 'LANG'):

View file

@ -771,18 +771,20 @@ def test_encoding_not_ignored(self, patch_expand_lang):
patch_expand_lang.assert_any_call('ga_IE.UTF-8')
self.env.unset('LANGUAGE')
@unittest.skipIf(os.name != "posix", "LC_MESSAGES is posix only")
def test_find_LANGUAGE_priority(self):
orig = locale.setlocale(locale.LC_MESSAGES)
self.addCleanup(lambda: locale.setlocale(locale.LC_MESSAGES, orig))
self.env.set('LANGUAGE', 'ga_IE')
self.env.set('LC_ALL', 'pt_BR')
if os.name != "posix":
orig = locale.setlocale(locale.LC_MESSAGES)
self.addCleanup(lambda: locale.setlocale(locale.LC_MESSAGES, orig))
locale.setlocale(locale.LC_MESSAGES, 'pt_BR')
mo_file = self.create_mo_file("ga_IE")
result = gettext.find("mofile", localedir=os.path.join(self.tempdir, "locale"))
self.assertEqual(result, mo_file)
locale.setlocale(locale.LC_MESSAGES, orig)
@unittest.skipIf(os.name != "posix", "LC_MESSAGES is posix only")
def test_process_vars_override(self):
orig = locale.setlocale(locale.LC_MESSAGES)
self.addCleanup(lambda: locale.setlocale(locale.LC_MESSAGES, orig))