Skip to content

Commit c0fcb16

Browse files
committed
Moved non_latin_locales.json to repo/assets/data/
1 parent ce658f0 commit c0fcb16

6 files changed

Lines changed: 24 additions & 45 deletions

File tree

remove-json-keys/src/remove_json_keys/assets/data/non_latin_locales.json renamed to assets/data/non_latin_locales.json

File renamed without changes.

remove-json-keys/src/remove_json_keys/assets/data/package_data.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"pypistats": "https://pypistats.org/packages/remove-json-keys",
2020
"support": "https://github.com/adamlui/python-utils/issues"
2121
},
22-
"commit_hashes": { "locales": "2e62364" }
22+
"commit_hashes": {
23+
"data": "ce658f0",
24+
"locales": "2e62364"
25+
}
2326
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ def get_msgs(cli: sn, lang_code: str = 'en') -> sn:
6767
mod_root_path / '_locales/en/messages.json'))
6868

6969
if not lang_code.startswith('en'): # fetch non-English msgs from jsDelivr
70-
non_latin_locales = data.json.read(mod_root_path / 'assets/data/non_latin_locales.json')
71-
if lang_code.split('-')[0] in non_latin_locales and not env.can_render_non_latin_scripts():
72-
return sn(**msgs) # en ones
70+
try: # check if terminal supports non-Latin scripts
71+
non_latin_locales = data.json.read(url.get(
72+
f'{cli.urls.jsdelivr}@{cli.commit_hashes.data}/assets/data/non_latin_locales.json'))
73+
if lang_code.split('-')[0] in non_latin_locales and not env.can_render_non_latin_scripts():
74+
return sn(**msgs) # en ones
75+
except Exception as err:
76+
log.debug(f'Failed to fetch non-Latin locales: {err}')
77+
7378
msg_base_url = f'{jsdelivr.create_commit_url(cli, cli.commit_hashes.locales)}/src/remove_json_keys/_locales'
7479
msg_url = f'{msg_base_url}/{lang_code}/messages.json'
7580
for attempt in range(3):

translate-messages/src/translate_messages/assets/data/non_latin_locales.json

Lines changed: 0 additions & 37 deletions
This file was deleted.

translate-messages/src/translate_messages/assets/data/package_data.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
"rw", "sg", "si", "sk", "sl", "sm", "sn", "so", "sr", "sv", "sw", "ta", "te", "tg", "th", "ti", "tk", "tn", "tpi",
2828
"tr", "uk", "ur", "uz", "vi", "xh", "yi", "zh", "zh-CN", "zh-HK", "zh-SG", "zh-TW", "zu"
2929
],
30-
"commit_hashes": { "locales": "2e62364" }
30+
"commit_hashes": {
31+
"data": "ce658f0",
32+
"locales": "2e62364"
33+
}
3134
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ def get_msgs(cli: sn, lang_code: str = 'en') -> sn:
9999
mod_root_path / '_locales/en/messages.json'))
100100

101101
if not lang_code.startswith('en'): # fetch non-English msgs from jsDelivr
102-
non_latin_locales = data.json.read(mod_root_path / 'assets/data/non_latin_locales.json')
103-
if lang_code.split('-')[0] in non_latin_locales and not env.can_render_non_latin_scripts():
104-
return sn(**msgs) # en ones
102+
try: # check if terminal supports non-Latin scripts
103+
non_latin_locales = data.json.read(url.get(
104+
f'{cli.urls.jsdelivr}@{cli.commit_hashes.data}/assets/data/non_latin_locales.json'))
105+
if lang_code.split('-')[0] in non_latin_locales and not env.can_render_non_latin_scripts():
106+
return sn(**msgs) # en ones
107+
except Exception as err:
108+
log.debug(f'Failed to fetch non-Latin locales: {err}')
109+
105110
msg_base_url = f'{jsdelivr.create_commit_url(cli, cli.commit_hashes.locales)}/src/remove_json_keys/_locales'
106111
msg_url = f'{msg_base_url}/{lang_code}/messages.json'
107112
for attempt in range(3):

0 commit comments

Comments
 (0)