add quart-babel
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
aiomqtt==2.3.2
|
||||
schema==0.7.7
|
||||
aiocron==2.1
|
||||
quart==0.20
|
||||
quart==0.20
|
||||
quart-babel==1.0.7
|
||||
2
app/src/.babel.cfg
Normal file
2
app/src/.babel.cfg
Normal file
@@ -0,0 +1,2 @@
|
||||
[python: **.py]
|
||||
[jinja2: web/templates/**.html]
|
||||
@@ -4,7 +4,8 @@ import logging.handlers
|
||||
import os
|
||||
import argparse
|
||||
from asyncio import StreamReader, StreamWriter
|
||||
from quart import Quart, Response
|
||||
from quart import Quart, Response, request
|
||||
from quart_babel import Babel
|
||||
from logging import config # noqa F401
|
||||
from proxy import Proxy
|
||||
from inverter_ifc import InverterIfc
|
||||
@@ -31,9 +32,20 @@ class ProxyState:
|
||||
ProxyState._is_up = value
|
||||
|
||||
|
||||
def get_locale():
|
||||
# hass.selectedLanguage
|
||||
logging.info("get_locale(%s)", request.accept_languages)
|
||||
return request.accept_languages.best_match(
|
||||
['de', 'en']
|
||||
)
|
||||
|
||||
|
||||
app = Quart(__name__,
|
||||
template_folder='web/templates',
|
||||
static_folder='web/static')
|
||||
babel = Babel(app,
|
||||
locale_selector=get_locale,
|
||||
default_translation_directories='../translations')
|
||||
app.register_blueprint(web_routes)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block title %} TSUN Proxy - Dashboard {% endblock title%}
|
||||
{% block menu1_class %}w3-blue{% endblock %}
|
||||
{% block headline %}<i class="fa fa-dashboard"></i> My Dashboard{% endblock headline %}
|
||||
{% block headline %}<i class="fa fa-dashboard"></i> {{_('My Dashboard')}}{% endblock headline %}
|
||||
|
||||
{% block content %}
|
||||
<div class="w3-row-padding w3-margin-bottom">
|
||||
|
||||
25
app/translations/de/LC_MESSAGES/messages.po
Normal file
25
app/translations/de/LC_MESSAGES/messages.po
Normal file
@@ -0,0 +1,25 @@
|
||||
# German translations for tsun-gen3-proxy.
|
||||
# Copyright (C) 2025 ORGANIZATION
|
||||
# This file is distributed under the same license as the tsun-gen3-proxy
|
||||
# project.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, 2025.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: tsun-gen3-proxy 0.14.0\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2025-04-18 20:46+0200\n"
|
||||
"PO-Revision-Date: 2025-04-18 16:24+0200\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: de\n"
|
||||
"Language-Team: de <LL@li.org>\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.17.0\n"
|
||||
|
||||
#: src/web/templates/index.html:5
|
||||
msgid "My Dashboard"
|
||||
msgstr "Mein Dashboard"
|
||||
|
||||
Reference in New Issue
Block a user