From 72049d9c8c5722f852e9e807a344fe3c708c0e2e Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Thu, 6 Apr 2023 20:49:08 +0200 Subject: [PATCH 1/2] Add option to find missing strings in only some locales --- scripts/frontend-development/find-missing-locales.py | 6 ++++-- website/docs/add_edit_translations.md | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/frontend-development/find-missing-locales.py b/scripts/frontend-development/find-missing-locales.py index 2080b196ed..bb9bdaba55 100644 --- a/scripts/frontend-development/find-missing-locales.py +++ b/scripts/frontend-development/find-missing-locales.py @@ -2,6 +2,7 @@ from glob import glob from json import load from os import path +import sys ALL_PATH = "../../website/public/locales/**/*.json" DIR = path.dirname(__file__) @@ -46,9 +47,10 @@ def main(): for en_file in glob(path.join(DIR, EN_PATH)): for file in glob(path.join(DIR, ALL_PATH)): if path.basename(en_file) == path.basename(file) and file != en_file: - file_info = audit(file, en_file) lang = path.basename(path.dirname(file)) - per_language_dict[lang].append(file_info) + if len(sys.argv) == 0 or lang in sys.argv: + file_info = audit(file, en_file) + per_language_dict[lang].append(file_info) for results in per_language_dict.values(): list(map(lambda args: print_result(*args), results)) print() diff --git a/website/docs/add_edit_translations.md b/website/docs/add_edit_translations.md index 63aff32c30..edea6284cc 100644 --- a/website/docs/add_edit_translations.md +++ b/website/docs/add_edit_translations.md @@ -33,6 +33,10 @@ When editing existing translations, follow these rules: ### Finding missing translations A script can be used to find missing and potentially untranslated locale files. Run the script from the root dir using -`python scripts/frontend-development/find-missing-locales.py`. +`python scripts/frontend-development/find-missing-locales.py`. +You may pass any languages you want to include in the search to the script like so: +`python scripts/frontend-development/find-missing-locales.py de ja` +This would only show missing/untranslated strings in the German (de) and Japanese (ja) locale files. +Passing nothing will default to searching all locales instead. If you have any questions or need further assistance, please reach out. From e24f5093e91142418d6dd5cb62be63b1d158ac2f Mon Sep 17 00:00:00 2001 From: Psychpsyo Date: Thu, 6 Apr 2023 21:03:04 +0200 Subject: [PATCH 2/2] Fix formatting --- scripts/frontend-development/find-missing-locales.py | 2 +- website/docs/add_edit_translations.md | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/frontend-development/find-missing-locales.py b/scripts/frontend-development/find-missing-locales.py index bb9bdaba55..c9a351234d 100644 --- a/scripts/frontend-development/find-missing-locales.py +++ b/scripts/frontend-development/find-missing-locales.py @@ -1,8 +1,8 @@ +import sys from collections import defaultdict from glob import glob from json import load from os import path -import sys ALL_PATH = "../../website/public/locales/**/*.json" DIR = path.dirname(__file__) diff --git a/website/docs/add_edit_translations.md b/website/docs/add_edit_translations.md index edea6284cc..35ee333614 100644 --- a/website/docs/add_edit_translations.md +++ b/website/docs/add_edit_translations.md @@ -33,10 +33,11 @@ When editing existing translations, follow these rules: ### Finding missing translations A script can be used to find missing and potentially untranslated locale files. Run the script from the root dir using -`python scripts/frontend-development/find-missing-locales.py`. -You may pass any languages you want to include in the search to the script like so: -`python scripts/frontend-development/find-missing-locales.py de ja` -This would only show missing/untranslated strings in the German (de) and Japanese (ja) locale files. +`python scripts/frontend-development/find-missing-locales.py`. + +You may pass any languages you want to include in the search to the script like so:\ +`python scripts/frontend-development/find-missing-locales.py de ja`\ +This would only show missing/untranslated strings in the German (de) and Japanese (ja) locale files.\ Passing nothing will default to searching all locales instead. If you have any questions or need further assistance, please reach out.