1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

feat(translate_apps): for every app component add as available languages for translation all the ones available in yunohost/core

This commit is contained in:
Laurent Peuch 2024-03-29 06:35:13 +01:00 committed by OniriCorpe
parent d8778a55b0
commit 2e5a2bbfa0

View file

@ -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"]
@ -143,6 +146,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)