- clean target erases the *.pot
- don't modify the resurt of url_for() calls - don't translate the language description
This commit is contained in:
@@ -21,6 +21,8 @@ export MAJOR := $(shell echo $(VERSION) | cut -f1 -d.)
|
||||
PUBLIC_URL := $(shell echo $(PUBLIC_CONTAINER_REGISTRY) | cut -f1 -d/)
|
||||
PUBLIC_USER :=$(shell echo $(PUBLIC_CONTAINER_REGISTRY) | cut -f2 -d/)
|
||||
|
||||
clean:
|
||||
rm -f $(BABEL_TRANSLATIONS)/*.pot
|
||||
|
||||
dev debug:
|
||||
@echo version: $(VERSION) build-date: $(BUILD_DATE) image: $(PRIVAT_CONTAINER_REGISTRY)$(IMAGE)
|
||||
@@ -58,4 +60,4 @@ $(BABEL_TRANSLATIONS)/%/LC_MESSAGES/messages.po : $(BABEL_TRANSLATIONS)/messages
|
||||
$(BABEL_TRANSLATIONS)/%/LC_MESSAGES/messages.mo : $(BABEL_TRANSLATIONS)/%/LC_MESSAGES/messages.po
|
||||
@pybabel compile -d $(BABEL_TRANSLATIONS) -l $*
|
||||
|
||||
.PHONY: babel debug dev preview rc rel
|
||||
.PHONY: babel clean debug dev preview rc rel
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from quart import request, session, redirect, abort
|
||||
from quart_babel import _
|
||||
from quart import request, session, redirect, abort, url_for
|
||||
from quart_babel.locale import get_locale as babel_get_locale
|
||||
|
||||
from . import web
|
||||
|
||||
LANGUAGES = {
|
||||
'en': _('English'),
|
||||
'de': _('German'),
|
||||
'fr': _('French')
|
||||
'en': 'English',
|
||||
'de': 'Deutsch',
|
||||
'fr': 'Français'
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +35,10 @@ def utility_processor():
|
||||
|
||||
|
||||
@web.route('/language/<language>')
|
||||
def set_language(language=None):
|
||||
async def set_language(language=None):
|
||||
if language in LANGUAGES:
|
||||
session['language'] = language
|
||||
return redirect(request.referrer)
|
||||
return abort(400)
|
||||
if request.referrer is not None:
|
||||
return redirect(request.referrer)
|
||||
return redirect(url_for('web.index'))
|
||||
return abort(404)
|
||||
|
||||
@@ -7,7 +7,7 @@ from . import web
|
||||
async def index():
|
||||
return await render_template(
|
||||
'index.html.j2',
|
||||
fetch_url='.'+url_for('web.data_fetch'))
|
||||
fetch_url=url_for('web.data_fetch'))
|
||||
|
||||
|
||||
@web.route('/page')
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<title>{% block title %}{% endblock title %}</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href=".{{ url_for('static', filename= 'css/style.css') }}">
|
||||
<link rel="stylesheet" href=".{{ url_for('static', filename= 'font-awesome/css/all.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename= 'css/style.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename= 'font-awesome/css/all.min.css') }}">
|
||||
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="shortcut icon" href="/favicon.ico" />
|
||||
@@ -14,7 +14,7 @@
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: Roboto;
|
||||
src: url(".{{ url_for('static', filename= 'font/roboto-light.ttf') }}");
|
||||
src: url("{{ url_for('static', filename= 'font/roboto-light.ttf') }}");
|
||||
}
|
||||
html,body,h1,h2,h3,h4,h5 {font-family: Roboto, sans-serif}
|
||||
</style>
|
||||
@@ -25,10 +25,10 @@
|
||||
<div class="w3-bar w3-dark-grey w3-large" style="z-index:4">
|
||||
<button class="w3-bar-item w3-button w3-hide-large" onclick="w3_open();"><i class="fa fa-bars"></i> Menu</button>
|
||||
<div class="w3-dropdown-hover w3-right">
|
||||
<button class="w3-button">{{_(lang_str)}}</button>
|
||||
<button class="w3-button">{{lang_str}}</button>
|
||||
<div class="w3-dropdown-content w3-bar-block w3-card-4" style="right:0">
|
||||
{% for language in languages %}
|
||||
<a href="./language/{{language}}" class="w3-bar-item w3-button">{{_(languages[language])}}</a>
|
||||
<a href="{{url_for('web.set_language', language=language)}}" class="w3-bar-item w3-button">{{languages[language]}}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -43,7 +43,7 @@
|
||||
<nav class="w3-sidebar w3-collapse w3-white" style="z-index:3;width:250px;" id="mySidebar"><br>
|
||||
<div class="w3-container w3-row">
|
||||
<div class="w3-col s4">
|
||||
<img src=".{{ url_for('static', filename= 'images/favicon.svg') }}" alt="" class="w3-circle w3-margin-right" style="width:60px">
|
||||
<img src="{{url_for('static', filename= 'images/favicon.svg') }}" alt="" class="w3-circle w3-margin-right" style="width:60px">
|
||||
</div>
|
||||
<div class="w3-col s8 w3-bar">
|
||||
<h3>TSUN-Proxy</h3><br>
|
||||
@@ -55,9 +55,9 @@
|
||||
</div>
|
||||
<div class="w3-bar-block">
|
||||
<button href="#" class="w3-bar-item w3-button w3-padding-16 w3-hide-large w3-dark-grey w3-hover-black" onclick="w3_close()" title="close menu"><i class="fa fa-remove fa-fw"></i> Close Menu</button>
|
||||
<a href=".{{ url_for('web.index')}}" class="w3-bar-item w3-button w3-padding {% block menu1_class %}{% endblock %}"><i class="fa fa-network-wired fa-fw"></i> {{_('Connections')}}</a>
|
||||
<a href=".{{ url_for('web.empty')}}" class="w3-bar-item w3-button w3-padding {% block menu2_class %}{% endblock %}"><i class="fa fa-database fa-fw"></i> MQTT</a>
|
||||
<a href=".{{ url_for('web.empty')}}" class="w3-bar-item w3-button w3-padding"><i class="fa fa-file-export fa-fw {% block menu3_class %}{% endblock %}"></i> Downloads</a>
|
||||
<a href="{{ url_for('web.index')}}" class="w3-bar-item w3-button w3-padding {% block menu1_class %}{% endblock %}"><i class="fa fa-network-wired fa-fw"></i> {{_('Connections')}}</a>
|
||||
<a href="{{ url_for('web.empty')}}" class="w3-bar-item w3-button w3-padding {% block menu2_class %}{% endblock %}"><i class="fa fa-database fa-fw"></i> MQTT</a>
|
||||
<a href="{{ url_for('web.empty')}}" class="w3-bar-item w3-button w3-padding"><i class="fa fa-file-export fa-fw {% block menu3_class %}{% endblock %}"></i> Downloads</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
|
||||
@@ -153,5 +153,5 @@ async def test_language_de(client):
|
||||
async def test_language_unknown(client):
|
||||
"""Test the language/en route."""
|
||||
response = await client.get('/language/unknonw')
|
||||
assert response.status_code == 400
|
||||
assert response.status_code == 404
|
||||
assert response.mimetype == 'text/html'
|
||||
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: tsun-gen3-proxy 0.14.0\n"
|
||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
|
||||
"POT-Creation-Date: 2025-04-27 01:25+0200\n"
|
||||
"POT-Creation-Date: 2025-04-28 20:37+0200\n"
|
||||
"PO-Revision-Date: 2025-04-18 16:24+0200\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language: de\n"
|
||||
@@ -19,18 +19,6 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Generated-By: Babel 2.17.0\n"
|
||||
|
||||
#: src/web/i18n.py:7
|
||||
msgid "English"
|
||||
msgstr "Englisch"
|
||||
|
||||
#: src/web/i18n.py:8
|
||||
msgid "German"
|
||||
msgstr "Deutsch"
|
||||
|
||||
#: src/web/i18n.py:9
|
||||
msgid "French"
|
||||
msgstr "Französisch"
|
||||
|
||||
#: src/web/templates/base.html.j2:37
|
||||
msgid "Updated:"
|
||||
msgstr "Aktualisiert:"
|
||||
|
||||
Reference in New Issue
Block a user