Skip to content

Commit

Permalink
ExtensionCore.py: Check for display names in translations (linuxmint#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rcalixte authored and JosephMcc committed Jun 30, 2024
1 parent a9499e8 commit d8f5ec5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions files/usr/share/cinnamon/cinnamon-settings/bin/ExtensionCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@

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

LANGUAGE_CODE = "C"
LANGUAGE_CODE = LONG_LANGUAGE_CODE = "C"
try:
LONG_LANGUAGE_CODE = locale.getlocale()[0]
LANGUAGE_CODE = locale.getlocale()[0].split("_")[0]
except:
pass
Expand Down Expand Up @@ -692,12 +693,15 @@ def __init__(self, uuid, data, spices, size_groups):
self.author = data['author_user']

if 'translations' in data.keys():
key = f'name_{LANGUAGE_CODE}'
if key in data['translations'].keys():
self.name = data['translations'][key]
key = f'description_{LANGUAGE_CODE}'
if key in data['translations'].keys():
self.description = data['translations'][key]
for key in (f'name_{LONG_LANGUAGE_CODE}', f'name_{LANGUAGE_CODE}'):
if key in data['translations'].keys():
self.name = data['translations'][key]
break

for key in (f'description_{LONG_LANGUAGE_CODE}', f'description_{LANGUAGE_CODE}'):
if key in data['translations'].keys():
self.description = data['translations'][key]
break

self.has_update = False

Expand Down

0 comments on commit d8f5ec5

Please sign in to comment.