aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdrien Hopkins <[email protected]>2022-08-25 07:52:33 -0500
committerAdrien Hopkins <[email protected]>2022-08-25 07:52:33 -0500
commitd9f6f5e9adca36ee83e5553e9a1b32704787a2d6 (patch)
treeabe98394deb42e18f7c3c8979dc873b33e106b62 /src
parent2629f3fed46dd884029a2c94cfbc0e54d49d34c2 (diff)
downloadcoinos-ui-d9f6f5e9adca36ee83e5553e9a1b32704787a2d6.tar.gz
coinos-ui-d9f6f5e9adca36ee83e5553e9a1b32704787a2d6.zip
translation script tells users if translation is already done
Diffstat (limited to 'src')
-rw-r--r--src/locales/guided_translation.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/locales/guided_translation.py b/src/locales/guided_translation.py
index 65f58db2..20abfd83 100644
--- a/src/locales/guided_translation.py
+++ b/src/locales/guided_translation.py
@@ -61,13 +61,13 @@ if __name__ == "__main__":
args_parser.add_argument('to_locale', nargs='?', type=str,
help="which locale to translate to")
args_parser.add_argument('-v', '--verbose', action='count', default=0,
- help="show more information")
+ help="show more information (use twice for even more)")
args_parser.add_argument('-V', '--version', action='store_true',
help="show version info and exit")
args = args_parser.parse_args()
if args.version:
- print("Guided Translation Script version 0.2.0")
+ print("Guided Translation Script version 0.3.0")
sys.exit(0)
from_locale = args.from_locale or input("Which locale do you want to translate from (default: %s)? "
@@ -110,17 +110,20 @@ if __name__ == "__main__":
len(to_id_list), to_locale)
logging.debug("List of strings: %s", to_id_list)
- # localize strings!
- try:
- for string_id in from_id_list:
- if string_id not in to_id_list:
- localize_string(string_id, from_data, to_data)
- to_id_list.append(string_id)
- except KeyboardInterrupt:
- print("\nProgram interrupted. Saving strings...")
+ if set(from_id_list) == set(to_id_list):
+ print("Translations are already complete.")
+ else:
+ # localize strings!
+ try:
+ for string_id in from_id_list:
+ if string_id not in to_id_list:
+ localize_string(string_id, from_data, to_data)
+ to_id_list.append(string_id)
+ except KeyboardInterrupt:
+ print("\nProgram interrupted. Saving strings...")
- # save localized data
- with open(to_locale + ".json", 'w', encoding='utf-8') as to_file:
- json.dump(to_data, to_file, ensure_ascii=False, indent='\t')
- to_file.write('\n')
- logging.info("Saved %d localized strings to %s.json", len(to_id_list), to_locale)
+ # save localized data
+ with open(to_locale + ".json", 'w', encoding='utf-8') as to_file:
+ json.dump(to_data, to_file, ensure_ascii=False, indent='\t')
+ to_file.write('\n')
+ logging.info("Saved %d localized strings to %s.json", len(to_id_list), to_locale)