mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
Merge ff2682c3da
into eb9f116bc5
This commit is contained in:
commit
0af45d9884
2 changed files with 39 additions and 9 deletions
|
@ -9,6 +9,7 @@ from copy import deepcopy
|
||||||
from typing import Dict, Optional, List, Tuple
|
from typing import Dict, Optional, List, Tuple
|
||||||
|
|
||||||
import toml
|
import toml
|
||||||
|
import glob
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
from babel.support import Translations
|
from babel.support import Translations
|
||||||
from babel.messages.pofile import PoFileParser
|
from babel.messages.pofile import PoFileParser
|
||||||
|
@ -106,7 +107,7 @@ def generate_READMEs(app_path: Path):
|
||||||
continue
|
continue
|
||||||
screenshots.append(str(entry.relative_to(app_path)))
|
screenshots.append(str(entry.relative_to(app_path)))
|
||||||
|
|
||||||
def generate_single_README(lang_suffix: str, lang: str):
|
def generate_single_README(lang_suffix: str, lang: str, translation_warning: bool = False):
|
||||||
env = Environment(
|
env = Environment(
|
||||||
loader=FileSystemLoader(README_GEN_DIR / "templates"),
|
loader=FileSystemLoader(README_GEN_DIR / "templates"),
|
||||||
extensions=["jinja2.ext.i18n"],
|
extensions=["jinja2.ext.i18n"],
|
||||||
|
@ -123,8 +124,10 @@ def generate_READMEs(app_path: Path):
|
||||||
# Fallback to english if maintainer too lazy to translate the description
|
# Fallback to english if maintainer too lazy to translate the description
|
||||||
elif (app_path / "doc" / "DESCRIPTION.md").exists():
|
elif (app_path / "doc" / "DESCRIPTION.md").exists():
|
||||||
description = (app_path / "doc" / "DESCRIPTION.md").read_text()
|
description = (app_path / "doc" / "DESCRIPTION.md").read_text()
|
||||||
|
translation_warning = True
|
||||||
else:
|
else:
|
||||||
description = None
|
description = None
|
||||||
|
translation_warning = True
|
||||||
|
|
||||||
disclaimer: Optional[str]
|
disclaimer: Optional[str]
|
||||||
if (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").exists():
|
if (app_path / "doc" / f"DISCLAIMER{lang_suffix}.md").exists():
|
||||||
|
@ -132,8 +135,10 @@ def generate_READMEs(app_path: Path):
|
||||||
# Fallback to english if maintainer too lazy to translate the disclaimer idk
|
# Fallback to english if maintainer too lazy to translate the disclaimer idk
|
||||||
elif (app_path / "doc" / "DISCLAIMER.md").exists():
|
elif (app_path / "doc" / "DISCLAIMER.md").exists():
|
||||||
disclaimer = (app_path / "doc" / "DISCLAIMER.md").read_text()
|
disclaimer = (app_path / "doc" / "DISCLAIMER.md").read_text()
|
||||||
|
translation_warning = True
|
||||||
else:
|
else:
|
||||||
disclaimer = None
|
disclaimer = None
|
||||||
|
translation_warning = True
|
||||||
|
|
||||||
# TODO: Add url to the documentation... and actually create that documentation :D
|
# TODO: Add url to the documentation... and actually create that documentation :D
|
||||||
antifeatures = {
|
antifeatures = {
|
||||||
|
@ -152,6 +157,7 @@ def generate_READMEs(app_path: Path):
|
||||||
)
|
)
|
||||||
|
|
||||||
out: str = template.render(
|
out: str = template.render(
|
||||||
|
translation_warning=translation_warning,
|
||||||
lang=lang,
|
lang=lang,
|
||||||
upstream=upstream,
|
upstream=upstream,
|
||||||
description=description,
|
description=description,
|
||||||
|
@ -165,19 +171,37 @@ def generate_READMEs(app_path: Path):
|
||||||
generate_single_README("", "en")
|
generate_single_README("", "en")
|
||||||
|
|
||||||
for lang in fully_translated_langs:
|
for lang in fully_translated_langs:
|
||||||
generate_single_README("_" + lang, lang)
|
generate_single_README("_" + lang, lang, False)
|
||||||
|
|
||||||
|
existing_READMEs_paths = glob.glob('README_*', root_dir=app_path)
|
||||||
|
existing_READMEs_langs = [name.removesuffix('.md').split('_')[-1] for name in existing_READMEs_paths]
|
||||||
|
other_existing_READMEs_langs = [x for x in existing_READMEs_langs if x not in fully_translated_langs]
|
||||||
|
|
||||||
|
for lang in other_existing_READMEs_langs:
|
||||||
|
generate_single_README("_" + lang, lang, True)
|
||||||
|
|
||||||
|
|
||||||
links_to_other_READMEs = []
|
links_to_other_READMEs = []
|
||||||
for language in fully_translated_langs:
|
fully_translated_or_existing_langs = list(set(fully_translated_langs) | set(existing_READMEs_langs)) # Union
|
||||||
|
for language in fully_translated_or_existing_langs:
|
||||||
translations = Translations.load("translations", [language])
|
translations = Translations.load("translations", [language])
|
||||||
language_name_in_itself = Language.get(language).autonym()
|
language_name_in_itself = Language.get(language).autonym()
|
||||||
links_to_other_READMEs.append(
|
if language in fully_translated_langs:
|
||||||
(
|
links_to_other_READMEs.append(
|
||||||
f"README_{language}.md",
|
(
|
||||||
translations.gettext("Read the README in %(language)s")
|
f"README_{language}.md",
|
||||||
% {"language": language_name_in_itself},
|
translations.gettext("Read the README in %(language)s")
|
||||||
|
% {"language": language_name_in_itself},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
elif language in other_existing_READMEs_langs:
|
||||||
|
links_to_other_READMEs.append(
|
||||||
|
(
|
||||||
|
f"README_{language}.md",
|
||||||
|
translations.gettext("Read the README in %(language)s (incomplete)")
|
||||||
|
% {"language": language_name_in_itself},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader(README_GEN_DIR / "templates"))
|
env = Environment(loader=FileSystemLoader(README_GEN_DIR / "templates"))
|
||||||
out: str = env.get_template("ALL_README.md.j2").render(
|
out: str = env.get_template("ALL_README.md.j2").render(
|
||||||
|
|
|
@ -25,7 +25,13 @@ It shall NOT be edited by hand.") }}
|
||||||
|
|
||||||
[](https://install-app.yunohost.org/?app={{manifest.id}})
|
[](https://install-app.yunohost.org/?app={{manifest.id}})
|
||||||
|
|
||||||
|
{% if translation_warning %}
|
||||||
|
> [!WARNING]
|
||||||
|
> {{ _("The README is not fully translated in this language. You may want to read this README [in other languages]") }}](./ALL_README.md))
|
||||||
|
> {{ _("Help would be appreciated for [completing the translation]")}}(https://translate.yunohost.org/projects/yunohost/readme-generator/{{lang}}).
|
||||||
|
{% else %}
|
||||||
*[{{ _("Read this README in other languages.") }}](./ALL_README.md)*
|
*[{{ _("Read this README in other languages.") }}](./ALL_README.md)*
|
||||||
|
{% endif -%}
|
||||||
|
|
||||||
> *{{ _("This package allows you to install %(application_name)s quickly and simply on a YunoHost server.")|format(application_name=manifest.name) }}*
|
> *{{ _("This package allows you to install %(application_name)s quickly and simply on a YunoHost server.")|format(application_name=manifest.name) }}*
|
||||||
> *{{ _("If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.") }}*
|
> *{{ _("If you don't have YunoHost, please consult [the guide](https://yunohost.org/install) to learn how to install it.") }}*
|
||||||
|
|
Loading…
Add table
Reference in a new issue