Skip to content

Commit 59451e9

Browse files
authored
ExtensionCore.py: Check for display names in translations (#12256)
Some language codes are only available as translations via their long language code format. This will check for the more precise long language code first before looking for the shorter and more general variation. This will improve translation support for how Spices modules are displayed before being installed locally.
1 parent f08780c commit 59451e9

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

files/usr/share/cinnamon/cinnamon-settings/bin/ExtensionCore.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@
3131

3232
UNSAFE_ITEMS = ['spawn_sync', 'spawn_command_line_sync', 'GTop', 'get_file_contents_utf8_sync']
3333

34-
LANGUAGE_CODE = "C"
34+
LANGUAGE_CODE = LONG_LANGUAGE_CODE = "C"
3535
try:
36+
LONG_LANGUAGE_CODE = locale.getlocale()[0]
3637
LANGUAGE_CODE = locale.getlocale()[0].split("_")[0]
3738
except:
3839
pass
@@ -692,12 +693,15 @@ def __init__(self, uuid, data, spices, size_groups):
692693
self.author = data['author_user']
693694

694695
if 'translations' in data.keys():
695-
key = f'name_{LANGUAGE_CODE}'
696-
if key in data['translations'].keys():
697-
self.name = data['translations'][key]
698-
key = f'description_{LANGUAGE_CODE}'
699-
if key in data['translations'].keys():
700-
self.description = data['translations'][key]
696+
for key in (f'name_{LONG_LANGUAGE_CODE}', f'name_{LANGUAGE_CODE}'):
697+
if key in data['translations'].keys():
698+
self.name = data['translations'][key]
699+
break
700+
701+
for key in (f'description_{LONG_LANGUAGE_CODE}', f'description_{LANGUAGE_CODE}'):
702+
if key in data['translations'].keys():
703+
self.description = data['translations'][key]
704+
break
701705

702706
self.has_update = False
703707

0 commit comments

Comments
 (0)