[tools] Exclude translations for languages not yet supported by the core

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk 2023-12-09 14:57:15 +01:00 committed by Alexander Borsuk
parent df840832dd
commit efafb16ae9

View file

@ -139,6 +139,26 @@ def usage():
else:
print('See https://www.soimort.org/translate-shell/ for installation instructions')
# Returns a list of all languages supported by the core (search) in data/categories.txt
def get_supported_categories_txt_languages():
script_dir = os.path.dirname(os.path.realpath(__file__))
categories_txt_path = os.path.join(script_dir, '..', '..', 'data', 'categories.txt')
languages = set()
with open(categories_txt_path) as f:
for line in f.readlines():
if not line: continue
if line[0] == '#': continue
colon_index = line.find(':')
# en: en-US: zh-Hant:
if colon_index == 2 or colon_index == 5 or colon_index == 7:
languages.add(line[:colon_index])
# Convert to list.
languages = list(languages)
languages.sort()
return languages
if __name__ == '__main__':
if len(sys.argv) < 2:
usage()
@ -172,9 +192,17 @@ if __name__ == '__main__':
langs = list(translations.keys())
langs.sort()
categories_txt_languages = get_supported_categories_txt_languages()
absent_in_categories_txt = [item for item in langs if item not in categories_txt_languages]
print('============ categories.txt format ============')
if len(absent_in_categories_txt) > 0:
print('\nWARNING: The following translations are not supported yet in the categories.txt and are skipped:')
print(absent_in_categories_txt)
print('See indexer/categories_holder.hpp for details.\n')
print('en:' + en)
for lang in langs:
if lang in absent_in_categories_txt:
continue
print(lang + ':' + translations[lang])
print('============ strings.txt format ============')