diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2024-02-18 02:41:40 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2024-02-18 02:41:40 +0300 |
commit | d79309e498cdc1358c81367ce2a93a5731e517d1 (patch) | |
tree | 675f200a986dfacd7d80787aa08570ef418ffa0a | |
parent | 688add1242be632837aad63832ebf7605f424079 (diff) |
web_kbn: use i18n in j2 templates
-rw-r--r-- | bin/web_kbn.py | 2 | ||||
-rw-r--r-- | web/kbn_templates/base.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/cams.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/index.j2 | 22 | ||||
-rw-r--r-- | web/kbn_templates/inverter.j2 | 6 | ||||
-rw-r--r-- | web/kbn_templates/modems.j2 | 2 | ||||
-rw-r--r-- | web/kbn_templates/pump.j2 | 12 | ||||
-rw-r--r-- | web/kbn_templates/sms.j2 | 14 |
8 files changed, 31 insertions, 31 deletions
diff --git a/bin/web_kbn.py b/bin/web_kbn.py index 9a99ab3..bf17046 100644 --- a/bin/web_kbn.py +++ b/bin/web_kbn.py @@ -190,7 +190,7 @@ class WebSite(http.HTTPServer): ) env = aiohttp_jinja2.get_env(self.app) - def filter_lang(key, unit): + def filter_lang(key, unit='web_kbn'): strings = Translation(unit) return strings.get()[key] diff --git a/web/kbn_templates/base.j2 b/web/kbn_templates/base.j2 index e2e29e3..dc1fd58 100644 --- a/web/kbn_templates/base.j2 +++ b/web/kbn_templates/base.j2 @@ -1,7 +1,7 @@ {% macro breadcrumbs(history) %} <nav aria-label="breadcrumb"> <ol class="breadcrumb"> - <li class="breadcrumb-item"><a href="main.cgi">Главная</a></li> + <li class="breadcrumb-item"><a href="main.cgi">{{ "main"|lang }}</a></li> {% for item in history %} <li class="breadcrumb-item"{% if loop.last %} aria-current="page"{% endif %}> {% if item.link %}<a href="{{ item.link }}">{% endif %} diff --git a/web/kbn_templates/cams.j2 b/web/kbn_templates/cams.j2 index 79cb64b..6459f90 100644 --- a/web/kbn_templates/cams.j2 +++ b/web/kbn_templates/cams.j2 @@ -1,6 +1,6 @@ {% extends "base.j2" %} {% block content %} -{{ breadcrumbs([{'text': 'Камеры'}]) }} +{{ breadcrumbs([{'text': "cams"|lang}]) }} {#<nav>#} {# <div class="nav nav-tabs" id="nav-tab">#} diff --git a/web/kbn_templates/index.j2 b/web/kbn_templates/index.j2 index cdf3026..e246dc5 100644 --- a/web/kbn_templates/index.j2 +++ b/web/kbn_templates/index.j2 @@ -4,7 +4,7 @@ <div class="container py-4"> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> - <li class="breadcrumb-item active" aria-current="page">Главная</li> + <li class="breadcrumb-item active" aria-current="page">{{ "main"|lang }}</li> </ol> </nav> @@ -14,24 +14,24 @@ <!-- </div>--> <!-- {% endif %}--> - <h6>Интернет</h6> + <h6>{{ "internet"|lang }}</h6> <ul class="list-group list-group-flush"> - <li class="list-group-item"><a href="/modems.cgi">Модемы</a></li> - <li class="list-group-item"><a href="/routing.cgi">Маршрутизация</a></li> - <li class="list-group-item"><a href="/sms.cgi">SMS-сообщения</a></li> + <li class="list-group-item"><a href="/modems.cgi">{{ "modems"|lang }}</a></li> + <li class="list-group-item"><a href="/routing.cgi">{{ "routing"|lang }}</a></li> + <li class="list-group-item"><a href="/sms.cgi">{{ "sms"|lang }}</a></li> </ul> - <h6 class="mt-4">Другое</h6> + <h6 class="mt-4">{{ "misc"|lang }}</h6> <ul class="list-group list-group-flush"> - <li class="list-group-item"><a href="/inverter.cgi">Инвертор</a> (<a href="{{ inverter_grafana_url }}">Grafana</a>)</li> - <li class="list-group-item"><a href="/pump.cgi">Насос</a></li> - <li class="list-group-item"><a href="/sensors.cgi">Датчики</a> (<a href="{{ sensors_grafana_url }}">Grafana</a>)</li> + <li class="list-group-item"><a href="/inverter.cgi">{{ "inverter"|lang }}</a> (<a href="{{ inverter_grafana_url }}">Grafana</a>)</li> + <li class="list-group-item"><a href="/pump.cgi">{{ "pump"|lang }}</a></li> + <li class="list-group-item"><a href="/sensors.cgi">{{ "sensors"|lang }}</a> (<a href="{{ sensors_grafana_url }}">Grafana</a>)</li> </ul> <nav class="mt-4"> <div class="nav nav-tabs" id="nav-tab"> - <button class="nav-link active" type="button" id="cam_zones_btn" data-id="zones">По зонам</button> - <button class="nav-link" type="button" id="cam_all_btn" data-id="all">Все камеры</button> + <button class="nav-link active" type="button" id="cam_zones_btn" data-id="zones">{{ "cams_by_zone"|lang }}</button> + <button class="nav-link" type="button" id="cam_all_btn" data-id="all">{{ "cams_all"|lang }}</button> </div> </nav> diff --git a/web/kbn_templates/inverter.j2 b/web/kbn_templates/inverter.j2 index 26491f3..e84bffc 100644 --- a/web/kbn_templates/inverter.j2 +++ b/web/kbn_templates/inverter.j2 @@ -1,16 +1,16 @@ {% extends "base.j2" %} {% block content %} -{{ breadcrumbs([{'text': 'Инвертор'}]) }} +{{ breadcrumbs([{'text': 'inverter'|lang}]) }} -<h6 class="text-primary">Статус</h6> +<h6 class="text-primary">{{ "inverter_status"|lang }}</h6> <div id="inverter_status"> {{ html|safe }} </div> <div class="pt-3"> <a href="/inverter.cgi?do=set-osp&value={{ 'sub' if rated.output_source_priority == 'Solar-Battery-Utility' else 'sbu' }}"> - <button type="button" class="btn btn-primary">Переключить на <b>{{ 'Solar-Utility-Battery' if rated.output_source_priority == 'Solar-Battery-Utility' else 'Solar-Battery-Utility' }}</b></button> + <button type="button" class="btn btn-primary">{{ "inverter_switch_to"|lang }} <b>{{ 'Solar-Utility-Battery' if rated.output_source_priority == 'Solar-Battery-Utility' else 'Solar-Battery-Utility' }}</b></button> </a> </div> {% endblock %} diff --git a/web/kbn_templates/modems.j2 b/web/kbn_templates/modems.j2 index 9defec3..a8a420d 100644 --- a/web/kbn_templates/modems.j2 +++ b/web/kbn_templates/modems.j2 @@ -1,7 +1,7 @@ {% extends "base.j2" %} {% block content %} -{{ breadcrumbs([{'text': 'Модемы'}]) }} +{{ breadcrumbs([{'text': 'modems'|lang}]) }} {% for modem in modems %} <h6 class="text-primary{% if not loop.first %} mt-4{% endif %}">{{ modems.getfullname(modem) }}</h6> diff --git a/web/kbn_templates/pump.j2 b/web/kbn_templates/pump.j2 index 28d5c9d..40836ca 100644 --- a/web/kbn_templates/pump.j2 +++ b/web/kbn_templates/pump.j2 @@ -1,17 +1,17 @@ {% extends "base.j2" %} {% block content %} -{{ breadcrumbs([{'text': 'Насос'}]) }} +{{ breadcrumbs([{'text': 'pump'|lang}]) }} <form action="/pump.cgi" method="get"> <input type="hidden" name="set" value="{{ 'off' if status == 'on' else 'on' }}" /> - Сейчас насос + {{ "pump_now_is"|lang }} {% if status == 'on' %} - <span class="text-success"><b>включен</b></span>.<br><br> - <button type="submit" class="btn btn-primary">Выключить</button> + <span class="text-success"><b>{{ "pump_now_on"|lang }}</b></span>.<br><br> + <button type="submit" class="btn btn-primary">{{ "pump_turn_off"|lang }}</button> {% else %} - <span class="text-danger"><b>выключен</b></span>.<br><br> - <button type="submit" class="btn btn-primary">Включить</button> + <span class="text-danger"><b>{{ "pump_now_off"|lang }}</b></span>.<br><br> + <button type="submit" class="btn btn-primary">{{ "pump_turn_on"|lang }}</button> {% endif %} </form> {% endblock %} diff --git a/web/kbn_templates/sms.j2 b/web/kbn_templates/sms.j2 index 6de9d42..cd91610 100644 --- a/web/kbn_templates/sms.j2 +++ b/web/kbn_templates/sms.j2 @@ -1,7 +1,7 @@ {% extends "base.j2" %} {% block content %} -{{ breadcrumbs([{'text': 'SMS-сообщения'}]) }} +{{ breadcrumbs([{'text': 'sms'|lang}]) }} <nav> <div class="nav nav-tabs" id="nav-tab"> @@ -13,11 +13,11 @@ </div> </nav> -<h6 class="text-primary mt-4">Отправить SMS</h6> +<h6 class="text-primary mt-4">{{ "sms_send_title"|lang }}</h6> {% if is_sent %} <div class="alert alert-success" role="alert"> - Сообщение отправлено. + {{ "sms_has_been_sent"|lang }} </div> {% elif error %} <div class="alert alert-danger" role="alert"> @@ -30,14 +30,14 @@ <input type="hidden" name="modem" value="{{ selected_modem }}"> <div class="form-floating mb-3"> <input type="text" name="phone" class="form-control" id="inputPhone" placeholder="+7911xxxyyzz"> - <label for="inputPhone">Телефон</label> + <label for="inputPhone">{{ "sms_phone"|lang }}</label> </div> <div class="form-floating"> <textarea class="form-control" id="inputTA" name="text" placeholder="Hello world" style="height: 100px"></textarea> - <label for="inputTA">Текст сообщения</label> + <label for="inputTA">{{ "sms_text"|lang }}</label> </div> <div class="mt-3"> - <button type="submit" class="btn btn-primary">Отправить</button> + <button type="submit" class="btn btn-primary">{{ "sms_send"|lang }}</button> </div> </form> </div> @@ -57,7 +57,7 @@ {{ m.Content }} </div> {% else %} - <span class="text-secondary">Сообщений нет.</span> + <span class="text-secondary">{{ "sms_no_messages"|lang }}</span> {% endfor %} {% endblock %}
\ No newline at end of file |