Interface translation test
This commit is contained in:
@ -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())
|
||||
|
Reference in New Issue
Block a user