Updated on 2026-08-14
This commit is contained in:
parent
ebe91678c7
commit
a55b4bc7b3
1 changed files with 7 additions and 7 deletions
14
lokalize.py
14
lokalize.py
|
|
@ -9,7 +9,7 @@
|
||||||
# 5) Use script when you need to download translations:
|
# 5) Use script when you need to download translations:
|
||||||
# > python3 lokalize.py
|
# > python3 lokalize.py
|
||||||
# In case you want to filter languages, just add --langs argument with specific values
|
# In case you want to filter languages, just add --langs argument with specific values
|
||||||
# > python3 lokalize.py --langs 'en' 'ru'
|
# > python3 lokalize.py --langs en,ru
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
@ -25,10 +25,10 @@ config = configparser.ConfigParser()
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--langs",
|
"--langs",
|
||||||
nargs="*",
|
nargs='?',
|
||||||
type=str,
|
type=str,
|
||||||
help="--langs 'en' 'ru'",
|
help="--langs en,ru",
|
||||||
default=[],
|
default='',
|
||||||
)
|
)
|
||||||
|
|
||||||
config_file_path = "local.properties"
|
config_file_path = "local.properties"
|
||||||
|
|
@ -39,7 +39,7 @@ token_key = "lokalise.token"
|
||||||
directory_prefix = "core/res/src/main/res/values-%LANG_ISO%/"
|
directory_prefix = "core/res/src/main/res/values-%LANG_ISO%/"
|
||||||
|
|
||||||
if not os.path.isfile(config_file_path):
|
if not os.path.isfile(config_file_path):
|
||||||
print("{config_file_path} not found!")
|
print(f"{config_file_path} not found!")
|
||||||
else:
|
else:
|
||||||
with open(config_file_path) as stream:
|
with open(config_file_path) as stream:
|
||||||
config.read_string(f'[{section_default}]\n' + stream.read())
|
config.read_string(f'[{section_default}]\n' + stream.read())
|
||||||
|
|
@ -50,7 +50,7 @@ else:
|
||||||
elif api_token is None:
|
elif api_token is None:
|
||||||
print(f"Key '{token_key}' not found in file {config_file_path}")
|
print(f"Key '{token_key}' not found in file {config_file_path}")
|
||||||
else:
|
else:
|
||||||
print(f"Found project: {project_id_key}")
|
print(f"Found project: {project_id}")
|
||||||
print(f"Found token: {api_token}")
|
print(f"Found token: {api_token}")
|
||||||
|
|
||||||
folder_path = "."
|
folder_path = "."
|
||||||
|
|
@ -68,7 +68,7 @@ else:
|
||||||
response = client.download_files(project_id, {
|
response = client.download_files(project_id, {
|
||||||
"format": "xml",
|
"format": "xml",
|
||||||
"original_filenames": True,
|
"original_filenames": True,
|
||||||
"filter_langs": args.langs,
|
"filter_langs": list(filter(None, args.langs.split(",") if args.langs is not None else "")),
|
||||||
"directory_prefix": directory_prefix,
|
"directory_prefix": directory_prefix,
|
||||||
"filter_data": ["translated"]
|
"filter_data": ["translated"]
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue