mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
appstore: fix i18n for description/pre_install notification
This commit is contained in:
parent
55e0a098ef
commit
62f246fba4
2 changed files with 12 additions and 11 deletions
|
@ -14,7 +14,7 @@ from flask import Flask, send_from_directory, render_template, session, redirect
|
||||||
from flask_babel import Babel
|
from flask_babel import Babel
|
||||||
from flask_babel import gettext as _
|
from flask_babel import gettext as _
|
||||||
from github import Github, InputGitAuthor
|
from github import Github, InputGitAuthor
|
||||||
from .utils import get_catalog, get_wishlist, get_stars, get_app_md_and_screenshots
|
from .utils import get_locale, get_catalog, get_wishlist, get_stars, get_app_md_and_screenshots
|
||||||
|
|
||||||
app = Flask(__name__, static_url_path='/assets', static_folder="assets")
|
app = Flask(__name__, static_url_path='/assets', static_folder="assets")
|
||||||
|
|
||||||
|
@ -48,13 +48,6 @@ if config.get("DEBUG"):
|
||||||
# This is the secret key used for session signing
|
# This is the secret key used for session signing
|
||||||
app.secret_key = config["COOKIE_SECRET"]
|
app.secret_key = config["COOKIE_SECRET"]
|
||||||
|
|
||||||
AVAILABLE_LANGUAGES = ["en"] + os.listdir("translations")
|
|
||||||
|
|
||||||
def get_locale():
|
|
||||||
# try to guess the language from the user accept
|
|
||||||
# header the browser transmits. We support de/fr/en in this
|
|
||||||
# example. The best match wins.
|
|
||||||
return request.accept_languages.best_match(AVAILABLE_LANGUAGES)
|
|
||||||
babel = Babel(app, locale_selector=get_locale)
|
babel = Babel(app, locale_selector=get_locale)
|
||||||
|
|
||||||
@app.template_filter('localize')
|
@app.template_filter('localize')
|
||||||
|
|
|
@ -5,6 +5,14 @@ import toml
|
||||||
import subprocess
|
import subprocess
|
||||||
import pycmarkgfm
|
import pycmarkgfm
|
||||||
from emoji import emojize
|
from emoji import emojize
|
||||||
|
from flask import request
|
||||||
|
|
||||||
|
|
||||||
|
AVAILABLE_LANGUAGES = ["en"] + os.listdir("translations")
|
||||||
|
def get_locale():
|
||||||
|
# try to guess the language from the user accept
|
||||||
|
# The best match wins.
|
||||||
|
return request.accept_languages.best_match(AVAILABLE_LANGUAGES)
|
||||||
|
|
||||||
def get_catalog():
|
def get_catalog():
|
||||||
|
|
||||||
|
@ -104,9 +112,9 @@ def human_to_binary(size: str) -> int:
|
||||||
|
|
||||||
def get_app_md_and_screenshots(app_folder, infos):
|
def get_app_md_and_screenshots(app_folder, infos):
|
||||||
|
|
||||||
locale = "en" # FIXME, deduce locale code from request
|
locale = get_locale()
|
||||||
|
|
||||||
if os.path.exists(os.path.join(app_folder, "doc", f"DESCRIPTION_{locale}.md")):
|
if locale != "en" and os.path.exists(os.path.join(app_folder, "doc", f"DESCRIPTION_{locale}.md")):
|
||||||
description_path = os.path.join(app_folder, "doc", f"DESCRIPTION_{locale}.md")
|
description_path = os.path.join(app_folder, "doc", f"DESCRIPTION_{locale}.md")
|
||||||
elif os.path.exists(os.path.join(app_folder, "doc", "DESCRIPTION.md")):
|
elif os.path.exists(os.path.join(app_folder, "doc", "DESCRIPTION.md")):
|
||||||
description_path = os.path.join(app_folder, "doc", "DESCRIPTION.md")
|
description_path = os.path.join(app_folder, "doc", "DESCRIPTION.md")
|
||||||
|
@ -118,7 +126,7 @@ def get_app_md_and_screenshots(app_folder, infos):
|
||||||
else:
|
else:
|
||||||
infos["full_description_html"] = infos['manifest']['description'][locale]
|
infos["full_description_html"] = infos['manifest']['description'][locale]
|
||||||
|
|
||||||
if os.path.exists(os.path.join(app_folder, "doc", f"PRE_INSTALL_{locale}.md")):
|
if locale != "en" and os.path.exists(os.path.join(app_folder, "doc", f"PRE_INSTALL_{locale}.md")):
|
||||||
pre_install_path = os.path.join(app_folder, "doc", f"PRE_INSTALL_{locale}.md")
|
pre_install_path = os.path.join(app_folder, "doc", f"PRE_INSTALL_{locale}.md")
|
||||||
elif os.path.exists(os.path.join(app_folder, "doc", "PRE_INSTALL.md")):
|
elif os.path.exists(os.path.join(app_folder, "doc", "PRE_INSTALL.md")):
|
||||||
pre_install_path = os.path.join(app_folder, "doc", "PRE_INSTALL.md")
|
pre_install_path = os.path.join(app_folder, "doc", "PRE_INSTALL.md")
|
||||||
|
|
Loading…
Add table
Reference in a new issue