1
0
Fork 0

fix(readme_generator/i18n): the template environnement was incorrectly loaded

This commit is contained in:
Laurent Peuch 2024-03-24 02:14:43 +01:00
parent dee76fa138
commit b7b077006e

View file

@ -87,13 +87,6 @@ def generate_READMEs(app_path: Path):
fully_translated_langs.sort() fully_translated_langs.sort()
env = Environment(
loader=FileSystemLoader(README_GEN_DIR / "templates"),
extensions=["jinja2.ext.i18n"],
)
translations = Translations.load("translations", ["fr", "en"])
env.install_gettext_translations(translations)
screenshots: List[str] = [] screenshots: List[str] = []
screenshots_dir = app_path / "doc" / "screenshots" screenshots_dir = app_path / "doc" / "screenshots"
@ -108,6 +101,13 @@ def generate_READMEs(app_path: Path):
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):
env = Environment(
loader=FileSystemLoader(README_GEN_DIR / "templates"),
extensions=["jinja2.ext.i18n"],
)
translations = Translations.load("translations", [lang])
env.install_gettext_translations(translations)
template = env.get_template("README.md.j2") template = env.get_template("README.md.j2")
if (app_path / "doc" / f"DESCRIPTION{lang_suffix}.md").exists(): if (app_path / "doc" / f"DESCRIPTION{lang_suffix}.md").exists():
@ -173,6 +173,7 @@ def generate_READMEs(app_path: Path):
) )
) )
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(
links_to_other_READMEs=links_to_other_READMEs links_to_other_READMEs=links_to_other_READMEs
) )