mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
chore: fix git absorb mess
This commit is contained in:
parent
f1798ed133
commit
d8778a55b0
2 changed files with 39 additions and 40 deletions
|
@ -46,10 +46,6 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
continue
|
||||
|
||||
if repository.run_command_as_if(["git", "rev-parse", "--verify", "origin/testing"]):
|
||||
repository.run_command(["git", "checkout", "-b", WORKING_BRANCH, "--track", "origin/testing"])
|
||||
if repository.run_command_as_if(
|
||||
["git", "rev-parse", "--verify", "origin/testing"]
|
||||
):
|
||||
repository.run_command(
|
||||
[
|
||||
"git",
|
||||
|
@ -60,6 +56,8 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
"origin/testing",
|
||||
]
|
||||
)
|
||||
branch = "testing"
|
||||
else:
|
||||
repository.run_command(["git", "checkout", "-b", WORKING_BRANCH])
|
||||
|
||||
manifest = tomlkit.loads(repository.read_file("manifest.toml"))
|
||||
|
@ -85,19 +83,6 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
if strings_to_translate not in manifest["install"][question]:
|
||||
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].indent(current_identation)
|
||||
|
||||
repository.write_file("manifest.toml", tomlkit.dumps(manifest))
|
||||
|
||||
if not repository.run_command("git status -s", capture_output=True).strip():
|
||||
continue
|
||||
|
||||
# create or update merge request
|
||||
repository.run_command("git diff")
|
||||
repository.run_command("git add manifest.toml")
|
||||
one_of_the_existing_languages = list(
|
||||
manifest["install"][question][strings_to_translate].keys()
|
||||
)[0]
|
||||
|
@ -112,19 +97,18 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
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):
|
||||
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:"])
|
||||
|
||||
time.sleep(2)
|
||||
repository.write_file("manifest.toml", tomlkit.dumps(manifest))
|
||||
|
||||
if not repository.run_command("git status -s", capture_output=True).strip():
|
||||
continue
|
||||
|
||||
if __name__ == "__main__":
|
||||
apps = json.load(open("../../builds/default/v3/apps.json"))["apps"]
|
||||
# create or update merge request
|
||||
repository.run_command("git diff")
|
||||
repository.run_command("git add manifest.toml")
|
||||
repository.run_command(["git", "commit", "-m", "feat(i18n): update translations for manifest.toml"])
|
||||
repository.run_command(["git", "push", "-f", "origin", f"{WORKING_BRANCH}:manifest_toml_i18n"])
|
||||
|
||||
with Repository(
|
||||
f"https://{login}:{token}@github.com/yunohost/apps_translations", "main"
|
||||
) as repository:
|
||||
extract_strings_to_translate_from_apps(apps, repository)
|
||||
if not repository.run_command(
|
||||
"hub pr list -h manifest_toml_i18n", capture_output=True
|
||||
):
|
||||
|
@ -140,6 +124,25 @@ if __name__ == "__main__":
|
|||
"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:",
|
||||
"This pull request is automatically generated by scripts from the "
|
||||
"[YunoHost/apps](https://github.com/YunoHost/apps) repository.\n\n"
|
||||
"The translation is pull from weblate and is located here: "
|
||||
f"https://translate.yunohost.org/projects/yunohost-apps/{app}/\n\n"
|
||||
"If 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:",
|
||||
]
|
||||
)
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
apps = json.load(open("../../builds/default/v3/apps.json"))["apps"]
|
||||
|
||||
with Repository(
|
||||
f"https://{login}:{token}@github.com/yunohost/apps_translations", "main"
|
||||
) as repository:
|
||||
extract_strings_to_translate_from_apps(apps, repository)
|
||||
|
|
|
@ -105,9 +105,7 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
for key, translated_string in translated_strings.items():
|
||||
if key not in language_file:
|
||||
language_file[key] = translated_string
|
||||
language_file = json.load(
|
||||
(translations_path / f"{language}.json").open()
|
||||
)
|
||||
|
||||
translations_repository.write_file(
|
||||
translations_path / f"{language}.json",
|
||||
json.dumps(language_file, indent=4, sort_keys=True),
|
||||
|
@ -128,19 +126,19 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
)
|
||||
translations_repository.run_command(["git", "push"])
|
||||
|
||||
if newly_created_translation or not get_weblate_component(weblate, f"yunohost-apps/{app}"):
|
||||
if newly_created_translation or not get_weblate_component(
|
||||
weblate, f"yunohost-apps/{app}"
|
||||
):
|
||||
print("Creating component on weblate...")
|
||||
weblate.create_component(
|
||||
"yunohost-apps",
|
||||
name=app,
|
||||
slug=app,
|
||||
if newly_created_translation or not get_weblate_component(
|
||||
weblate, f"yunohost-apps/{app}"
|
||||
):
|
||||
filemask=f"translations/apps/{app}/*.json",
|
||||
file_format="json",
|
||||
filemask=f"translations/apps/{app}/manifest/*.json",
|
||||
repo="https://github.com/yunohost/apps_translations",
|
||||
new_base=f"translations/apps/{app}/en.json",
|
||||
template=f"translations/apps/{app}/en.json",
|
||||
new_base=f"translations/apps/{app}/manifest/en.json",
|
||||
template=f"translations/apps/{app}/manifest/en.json",
|
||||
push="git@github.com:yunohost/apps_translations.git",
|
||||
)
|
||||
print(f"Component created at https://translate.yunohost.org/projects/yunohost-apps/{app}/")
|
||||
|
@ -149,9 +147,7 @@ def extract_strings_to_translate_from_apps(apps, translations_repository):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(
|
||||
f"Component created at https://translate.yunohost.org/projects/yunohost-apps/{app}/"
|
||||
)
|
||||
apps = json.load(open("../../builds/default/v3/apps.json"))["apps"]
|
||||
|
||||
with Repository(
|
||||
f"https://{login}:{token}@github.com/yunohost/apps_translations", "main"
|
||||
|
|
Loading…
Add table
Reference in a new issue