From fe0713f87e8efcb4bb7aa27a312395c733717bfd Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 29 Mar 2024 06:35:13 +0100 Subject: [PATCH] feat(translate_apps): for every app component add as available languages for translation all the ones available in yunohost/core --- tools/translate_apps/push_or_update_apps_on_repository.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/translate_apps/push_or_update_apps_on_repository.py b/tools/translate_apps/push_or_update_apps_on_repository.py index c56f2994c7..a204e9a4e6 100644 --- a/tools/translate_apps/push_or_update_apps_on_repository.py +++ b/tools/translate_apps/push_or_update_apps_on_repository.py @@ -22,6 +22,9 @@ def get_weblate_component(weblate, component_path): def extract_strings_to_translate_from_apps(apps, translations_repository): weblate = wlc.Weblate(key=weblate_token, url="https://translate.yunohost.org/api/") + # put all languages used on core by default for each component + core_languages_list = {x["language_code"] for x in weblate.get("components/yunohost/core/translations/")["results"]} + for app, infos in apps.items(): repository_uri = infos["git"]["url"].replace("https://github.com/", "") branch = infos["git"]["branch"] @@ -145,6 +148,11 @@ def extract_strings_to_translate_from_apps(apps, translations_repository): ) print(f"Component created at https://translate.yunohost.org/projects/yunohost-apps/{app}/") + component_existing_languages = {x["language_code"] for x in weblate.get(f"components/yunohost-apps/{app}/translations/")["results"]} + for language_code in sorted(core_languages_list - component_existing_languages): + print(f"Adding available language for translation: {language_code}") + weblate.post(f"components/yunohost-apps/{app}/translations/", **{"language_code": language_code}) + time.sleep(2)