diff --git a/constants.py b/constants.py
index 3936be0..736d286 100644
--- a/constants.py
+++ b/constants.py
@@ -8,9 +8,9 @@ lang_dict = {}
def load_lang(lang):
global lang_dict, default_lang_dict
- with open("lang/en_US", "r") as f:
+ with open("lang/en_US.json", "r") as f:
default_lang_dict = json.load(f)
- with open(f"lang/{lang}", "r") as f:
+ with open(f"lang/{lang}.json", "r") as f:
lang_dict = json.load(f)
diff --git a/lang/en_US b/lang/en_US.json
similarity index 98%
rename from lang/en_US
rename to lang/en_US.json
index e4549f1..db7a6af 100644
--- a/lang/en_US
+++ b/lang/en_US.json
@@ -4,8 +4,8 @@
"added_tags_to_all": "Added tags {tags} to songs on the playlist.",
"admin_help": "
Admin command
\nBot\n\n- !kill - kill the bot
\n- !update - update the bot
\n- !userban {user} - ban a user
\n- !userunban {user} - unban a user
\n- !urlbanlist - list banned url
\n- !urlban [{url}] - ban {url} (or current item's url by default) and remove this url from the library.
\n- !urlunban {url} - unban {url}
\n- !rescan {url} - rebuild local music file cache
\n- !dropdatabase - clear the entire database, you will lose all settings and music library.
\n
\nWeb Interface\n\n- !webuserlist - list all users that have the permission of accessing the web interface, if auth mode is 'password'.
\n- !webuseradd {nick name} - grant the user with {nick name} the access to the web interface, if auth mode is 'password'.
\n- !webuserdel {nick name} - revoke the access to the web interface of {nick name}, if auth mode is 'password'.
\n- !update - update the bot
\n- !userban {user} - ban a user
\n
",
"auto_paused": "Use !play to resume music!",
- "bad_command": "{{command}}: command not found.",
- "bad_parameter": "{command}: invalid parameter.",
+ "bad_command": "{command}: command not found.",
+ "bad_parameter": "{command}: invalid parameter.",
"bad_url": "Bad URL requested.",
"cache_refreshed": "Cache refreshed!",
"change_ducking_volume": "Volume on ducking set to {volume} by {user}.",
diff --git a/lang/sync_translation.py b/lang/sync_translation.py
index 22fafba..67fb20b 100755
--- a/lang/sync_translation.py
+++ b/lang/sync_translation.py
@@ -39,30 +39,30 @@ def fetch_translation(r_client, r_secret):
params = {'locale': lang_code,
'format': 'jsonnested'}
r = requests.get(f"{base_url}/projects/{project_id}/exports", params=params, headers=headers)
- with open(lang_code, "wb") as f:
+ with open(lang_code + ".json", "wb") as f:
f.write(r.content)
def push_strings(w_client, w_secret):
- print("Pushing local en_US file into the remote host...")
+ print("Pushing local translation files into the remote host...")
headers = get_access_header(w_client, w_secret)
lang_files = os.listdir('.')
lang_list = []
for lang_file in lang_files:
- match = re.search("[a-z]{2}_[A-Z]{2}", lang_file)
+ match = re.search("([a-z]{2}_[A-Z]{2})\.json", lang_file)
if match:
- lang_list.append(lang_file)
+ lang_list.append(match[1])
- for lang_file in lang_list:
- print(f" - Pushing {lang_file}")
+ for lang in lang_list:
+ print(f" - Pushing {lang}")
- params = {'locale': lang_file,
+ params = {'locale': lang,
'format': 'jsonnested'}
- files = {'file': open(lang_file, 'r')}
+ files = {'file': open(lang + ".json", 'r')}
r = requests.post(f"{base_url}/projects/{project_id}/imports", params=params, headers=headers, files=files)
- assert r.status_code == 200, f"Unable to push {lang_file} into remote host. {r.status_code}"
+ assert r.status_code == 200, f"Unable to push {lang} into remote host. {r.status_code}"
if __name__ == "__main__":
diff --git a/util.py b/util.py
index c4723f1..6589881 100644
--- a/util.py
+++ b/util.py
@@ -419,9 +419,9 @@ def get_supported_language():
lang_files = os.listdir('lang')
lang_list = []
for lang_file in lang_files:
- match = re.search("[a-z]{2}_[A-Z]{2}", lang_file)
+ match = re.search("([a-z]{2}_[A-Z]{2})\.json", lang_file)
if match:
- lang_list.append(lang_file)
+ lang_list.append(match[1])
return lang_list