Skip to content

Commit 44f6028

Browse files
committed
1 parent b9fa575 commit 44f6028

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

translate-messages/__main__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from lib import init
33
from sys import stdout
44
from translate import Translator
5+
from urllib.error import URLError, HTTPError
56
from urllib.request import urlopen
67

78
env = init.env()
@@ -14,8 +15,13 @@
1415
try: # try to fetch template from jsDelivr
1516
jsd_url = f'{cli.urls.jsdelivr}/{cli.name}/{cli.config_filename}'
1617
with urlopen(jsd_url) as resp:
17-
if resp.status == 200 : cli.config_data = json.loads(resp.read().decode('utf-8'))
18-
except Exception : pass
18+
if resp.status == 200:
19+
cli.config_data = json.loads(resp.read().decode('utf-8'))
20+
else:
21+
raise ValueError('Non-200 response')
22+
except (URLError, HTTPError, json.JSONDecodeError, ValueError):
23+
cli.config_data = {}
24+
1925
with open(cli.config_path, 'w', encoding='utf-8') as configFile:
2026
json.dump(cli.config_data, configFile, indent=2)
2127
print(f'Default config created at {cli.config_path}')

translate-messages/lib/init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def parse_csv_val(val) : return [item.strip() for item in val.split(',') if item
55
def cli(callerFile):
66
cli = sns(
77
name='translate-messages',
8-
version='2026.2.10.38',
8+
version='2026.2.10.39',
99
author=sns(name='Adam Lui', email='adam@kudoa.com', url='https://github.com/adamlui'),
1010
description='Translate en/messages.json to other locales',
1111
urls=sns(

0 commit comments

Comments
 (0)