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

fix(translate_apps): correctly indent a new translation

This commit is contained in:
Laurent Peuch 2024-03-28 07:51:31 +01:00 committed by OniriCorpe
parent 1fd3f96d0e
commit 8025e1d5d7

View file

@ -83,7 +83,10 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
if strings_to_translate not in manifest["install"][question]: if strings_to_translate not in manifest["install"][question]:
continue continue
one_of_the_existing_languages = list(manifest["install"][question][strings_to_translate].keys())[0]
current_identation = len(manifest["install"][question][strings_to_translate][one_of_the_existing_languages].trivia.indent)
manifest["install"][question][strings_to_translate][language] = translation[translation_key] manifest["install"][question][strings_to_translate][language] = translation[translation_key]
manifest["install"][question][strings_to_translate][language].indent(current_identation)
repository.write_file("manifest.toml", tomlkit.dumps(manifest)) repository.write_file("manifest.toml", tomlkit.dumps(manifest))
@ -93,10 +96,20 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
# create or update merge request # create or update merge request
repository.run_command("git diff") repository.run_command("git diff")
repository.run_command("git add manifest.toml") repository.run_command("git add manifest.toml")
repository.run_command(["git", "commit", "-m", "feat(i18n): update translations for manifest.toml"]) one_of_the_existing_languages = list(
repository.run_command(["git", "push", "-f", "origin", f"{WORKING_BRANCH}:manifest_toml_i18n"]) manifest["install"][question][strings_to_translate].keys()
)[0]
# if no PR exist, create one current_identation = len(
manifest["install"][question][strings_to_translate][
one_of_the_existing_languages
].trivia.indent
)
manifest["install"][question][strings_to_translate][
language
] = translation[translation_key]
manifest["install"][question][strings_to_translate][
language
].indent(current_identation)
if not repository.run_command("hub pr list -h manifest_toml_i18n", capture_output=True): if not repository.run_command("hub pr list -h manifest_toml_i18n", capture_output=True):
repository.run_command(["hub", "pull-request", "-m", "Update translations for manifest.toml", "-b", branch, "-h", "manifest_toml_i18n", "-p", "-m", f"This pull request is automatically generated by scripts from the [YunoHost/apps](https://github.com/YunoHost/apps) repository.\n\nThe translation is pull from weblate and is located here: https://translate.yunohost.org/projects/yunohost-apps/{app}/\n\nIf you wish to modify the translation (other than in english), please do that directly on weblate since this is now the source of authority for it.\n\nDon't hesitate to reach the YunoHost team on [matrix](https://matrix.to/#/#yunohost:matrix.org) if there is any problem :heart:"]) repository.run_command(["hub", "pull-request", "-m", "Update translations for manifest.toml", "-b", branch, "-h", "manifest_toml_i18n", "-p", "-m", f"This pull request is automatically generated by scripts from the [YunoHost/apps](https://github.com/YunoHost/apps) repository.\n\nThe translation is pull from weblate and is located here: https://translate.yunohost.org/projects/yunohost-apps/{app}/\n\nIf you wish to modify the translation (other than in english), please do that directly on weblate since this is now the source of authority for it.\n\nDon't hesitate to reach the YunoHost team on [matrix](https://matrix.to/#/#yunohost:matrix.org) if there is any problem :heart:"])