Skip to content

Commit

Permalink
feat(translate_apps): for every app component add as available langua…
Browse files Browse the repository at this point in the history
…ges for translation all the ones available in yunohost/core
  • Loading branch information
Psycojoker committed Mar 29, 2024
1 parent d721ee4 commit fe0713f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/translate_apps/push_or_update_apps_on_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit fe0713f

Please sign in to comment.