Skip to content

Commit 819b7d4

Browse files
committed
Moved non-Latin locale check to internet block, dropped region check
1 parent e1d7ffc commit 819b7d4

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

remove-json-keys/src/remove_json_keys/lib/language.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ def get_msgs(cli: sn, lang_code: str = 'en') -> sn:
6363
return get_msgs.cached # don't re-fetch same msgs
6464

6565
mod_root_path = Path(__file__).parent.parent
66-
non_latin_locales = data.json.read(mod_root_path / 'assets/data/non_latin_locales.json')
6766
msgs = data.json.flatten(data.json.read( # local ones
6867
mod_root_path / '_locales/en/messages.json'))
6968

70-
if (
71-
not lang_code.startswith('en') and
72-
not (lang_code in non_latin_locales and not env.can_render_non_latin_scripts())
73-
): # fetch non-English msgs from jsDelivr
69+
if not lang_code.startswith('en'): # fetch non-English msgs from jsDelivr
70+
# Check if terminal supports non-Latin scripts
71+
non_latin_locales = data.json.read(mod_root_path / 'assets/data/non_latin_locales.json')
72+
if lang_code.split('-')[0] in non_latin_locales and not env.can_render_non_latin_scripts():
73+
return sn(**msgs) # en ones
7474
msg_base_url = f'{jsdelivr.create_commit_url(cli, cli.commit_hashes.locales)}/src/remove_json_keys/_locales'
7575
msg_url = f'{msg_base_url}/{lang_code}/messages.json'
7676
for attempt in range(3):

translate-messages/src/translate_messages/lib/language.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ def get_msgs(cli: sn, lang_code: str = 'en') -> sn:
9595
return get_msgs.cached # don't re-fetch same msgs
9696

9797
mod_root_path = Path(__file__).parent.parent
98-
non_latin_locales = data.json.read(mod_root_path / 'assets/data/non_latin_locales.json')
9998
msgs = data.json.flatten(data.json.read( # local ones
10099
mod_root_path / '_locales/en/messages.json'))
101100

102-
if (
103-
not lang_code.startswith('en') and
104-
not (lang_code in non_latin_locales and not env.can_render_non_latin_scripts())
105-
): # fetch non-English msgs from jsDelivr
101+
if not lang_code.startswith('en'): # fetch non-English msgs from jsDelivr
102+
# Check if terminal supports non-Latin scripts
103+
non_latin_locales = data.json.read(mod_root_path / 'assets/data/non_latin_locales.json')
104+
if lang_code.split('-')[0] in non_latin_locales and not env.can_render_non_latin_scripts():
105+
return sn(**msgs) # en ones
106106
msg_base_url = f'{jsdelivr.create_commit_url(cli, cli.commit_hashes.locales)}/src/remove_json_keys/_locales'
107107
msg_url = f'{msg_base_url}/{lang_code}/messages.json'
108108
for attempt in range(3):

0 commit comments

Comments
 (0)