Interface translation test

This commit is contained in:
Félix Aime
2021-02-04 11:11:43 +01:00
parent a6c88b7cea
commit 30d08c544b
14 changed files with 378 additions and 155 deletions

View File

@ -4,6 +4,7 @@
import subprocess as sp
from flask import Blueprint, jsonify
from app.utils import read_config
import re
misc_bp = Blueprint("misc", __name__)
@ -59,3 +60,18 @@ def get_config():
"reboot_option": read_config(("frontend", "reboot_option")),
"iface_out": read_config(("network", "out"))
})
@app.route("/get-lang", methods=["GET"])
def get_lang():
"""
Get the user lang defined in the config.yaml
and retrieve the interface translation.
"""
lang = read_config(("frontend", "user_lang"))
if re.match("^[a-z]{2,3}$", lang):
with open("app/assets/lang/{}.json".format(lang), "r") as f:
return(f.read())
else:
with open("app/assets/lang/en.json", "r") as f:
return(f.read())