From 987a216306c1668457acc9b2bb616a70c5a87687 Mon Sep 17 00:00:00 2001 From: level09 Date: Sat, 25 Jul 2026 12:44:59 +0300 Subject: [PATCH 01/12] fix(i18n): render locale language and text direction in layouts --- enferno/app.py | 17 +++++++++++++++++ enferno/static/css/app.css | 4 ++++ enferno/static/js/common/config.js | 4 ++++ enferno/templates/layout.html | 2 +- enferno/templates/login-layout.html | 2 +- enferno/templates/security/base.html | 2 +- enferno/templates/setup_wizard.html | 6 +++++- tests/test_rtl.py | 23 +++++++++++++++++++++++ 8 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 tests/test_rtl.py diff --git a/enferno/app.py b/enferno/app.py index 93699536a..b4faaa769 100755 --- a/enferno/app.py +++ b/enferno/app.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import pandas as pd +from babel import Locale from urllib.parse import urlparse from flask import Flask, render_template, current_app, request from flask_login import user_logged_in, user_logged_out @@ -107,12 +108,28 @@ def create_app(config_object=Config): register_constants(app) register_blueprints(app) register_extensions(app) + register_template_context(app) register_shellcontext(app) register_commands(app) register_signals(app) return app +def register_template_context(app): + @app.context_processor + def locale_context(): + locale = str(get_locale()) + direction = ( + "rtl" + if Locale.parse(locale.replace("-", "_")).character_order == "right-to-left" + else "ltr" + ) + return { + "current_language": locale.replace("_", "-"), + "current_direction": direction, + } + + def register_extensions(app): """ Register Flask extensions. diff --git a/enferno/static/css/app.css b/enferno/static/css/app.css index 4db89966f..9934e7e1e 100644 --- a/enferno/static/css/app.css +++ b/enferno/static/css/app.css @@ -305,6 +305,10 @@ button.swh { float: right; } +[dir="rtl"] .vue-query-builder button.pull-right { + float: left; +} + .smaller { transform: scale(0.9); diff --git a/enferno/static/js/common/config.js b/enferno/static/js/common/config.js index 0522469fd..9fef421b8 100644 --- a/enferno/static/js/common/config.js +++ b/enferno/static/js/common/config.js @@ -166,6 +166,10 @@ const variables = { 'pointer-events-auto': 'auto', } const vuetifyConfig = { + locale: { + locale: window.__lang__ || document.documentElement.lang, + fallback: 'en', + }, defaults: { VRow: { dense: true, diff --git a/enferno/templates/layout.html b/enferno/templates/layout.html index cae303ec5..2ed85a43d 100644 --- a/enferno/templates/layout.html +++ b/enferno/templates/layout.html @@ -1,5 +1,5 @@ - + {{ _('Bayanat') }} diff --git a/enferno/templates/login-layout.html b/enferno/templates/login-layout.html index 05486369b..43426e4ee 100644 --- a/enferno/templates/login-layout.html +++ b/enferno/templates/login-layout.html @@ -1,5 +1,5 @@ - + {{ _('Bayanat') }} diff --git a/enferno/templates/security/base.html b/enferno/templates/security/base.html index f94a19d92..93c750b28 100644 --- a/enferno/templates/security/base.html +++ b/enferno/templates/security/base.html @@ -1,6 +1,6 @@ {% block doc -%} - + {%- block html %} {%- block head %} diff --git a/enferno/templates/setup_wizard.html b/enferno/templates/setup_wizard.html index a1aea5287..eabb0962e 100644 --- a/enferno/templates/setup_wizard.html +++ b/enferno/templates/setup_wizard.html @@ -1,5 +1,5 @@ - + {{ _(' Setup Bayanat') }} @@ -446,6 +446,10 @@

{{ _('Two Factor Authentication Policies') }}' in response.text + + +def test_english_layout_remains_ltr(anonymous_client): + response = anonymous_client.get("/login") + + assert response.status_code == 200 + assert '' in response.text + + +def test_authenticated_layout_exposes_direction(admin_client, monkeypatch): + monkeypatch.setattr("enferno.app.get_locale", lambda: "ar") + + response = admin_client.get("/admin/labels/") + + assert response.status_code == 200 + assert '' in response.text From 4af2b937f5842b0515b977243750e733479d719c Mon Sep 17 00:00:00 2001 From: level09 Date: Sat, 25 Jul 2026 12:49:12 +0300 Subject: [PATCH 02/12] fix(i18n): use logical CSS properties and drawer locations for RTL --- .../admin/templates/admin/actor-fields.html | 2 +- .../templates/admin/bulletin-fields.html | 2 +- enferno/admin/templates/admin/bulletins.html | 4 +- .../templates/admin/incident-fields.html | 2 +- .../admin/partials/actor_drawer.html | 4 +- .../admin/partials/bulk_actor_drawer.html | 2 +- .../admin/partials/bulk_bulletin_drawer.html | 2 +- .../admin/partials/bulk_incident_drawer.html | 2 +- .../admin/partials/bulletin_drawer.html | 4 +- .../admin/partials/export_drawer.html | 4 +- .../admin/partials/incident_drawer.html | 4 +- .../admin/partials/location_drawer.html | 4 +- .../templates/admin/partials/user_drawer.html | 4 +- .../admin/system-administration.html | 2 +- enferno/admin/templates/nav-bar.html | 12 ++-- enferno/export/templates/export_drawer.html | 4 +- enferno/static/css/app.css | 3 +- enferno/static/img/bayanat-h-w-v2.svg | 2 +- enferno/static/js/common/config.js | 3 - enferno/static/js/components/EventsSection.js | 2 +- .../js/components/InlineMediaRenderer.js | 8 +-- .../static/js/components/MapVisualization.js | 43 +++++++++--- enferno/static/js/components/MediaRedactor.js | 10 +-- .../js/components/MediaTranscriptionDialog.js | 14 ++-- .../static/js/components/NotificationsList.js | 4 +- .../static/js/components/ProfileDropdown.js | 8 +-- enferno/templates/notifications_drawer.html | 4 +- tests/test_rtl.py | 68 +++++++++++++++++++ 28 files changed, 158 insertions(+), 69 deletions(-) diff --git a/enferno/admin/templates/admin/actor-fields.html b/enferno/admin/templates/admin/actor-fields.html index 8647cf333..5b1e69aac 100644 --- a/enferno/admin/templates/admin/actor-fields.html +++ b/enferno/admin/templates/admin/actor-fields.html @@ -20,7 +20,7 @@ - \ No newline at end of file + diff --git a/enferno/admin/templates/admin/partials/bulk_actor_drawer.html b/enferno/admin/templates/admin/partials/bulk_actor_drawer.html index 5a9b439c0..c7080a636 100644 --- a/enferno/admin/templates/admin/partials/bulk_actor_drawer.html +++ b/enferno/admin/templates/admin/partials/bulk_actor_drawer.html @@ -1,7 +1,7 @@ diff --git a/enferno/admin/templates/admin/partials/bulk_bulletin_drawer.html b/enferno/admin/templates/admin/partials/bulk_bulletin_drawer.html index da1ee8550..167e5ee99 100644 --- a/enferno/admin/templates/admin/partials/bulk_bulletin_drawer.html +++ b/enferno/admin/templates/admin/partials/bulk_bulletin_drawer.html @@ -1,7 +1,7 @@ diff --git a/enferno/admin/templates/admin/partials/bulletin_drawer.html b/enferno/admin/templates/admin/partials/bulletin_drawer.html index eb821108a..aacd8c414 100644 --- a/enferno/admin/templates/admin/partials/bulletin_drawer.html +++ b/enferno/admin/templates/admin/partials/bulletin_drawer.html @@ -2,7 +2,7 @@ v-model="bulletinDrawer" clipped fixed - location="right" + location="end" temporary width="520" app @@ -24,4 +24,4 @@ :bulletin="bulletin"> - \ No newline at end of file + diff --git a/enferno/admin/templates/admin/partials/export_drawer.html b/enferno/admin/templates/admin/partials/export_drawer.html index 93d373c9d..1d605b0aa 100644 --- a/enferno/admin/templates/admin/partials/export_drawer.html +++ b/enferno/admin/templates/admin/partials/export_drawer.html @@ -1,7 +1,7 @@ - \ No newline at end of file + diff --git a/enferno/admin/templates/admin/partials/incident_drawer.html b/enferno/admin/templates/admin/partials/incident_drawer.html index 09abda34f..acb376839 100644 --- a/enferno/admin/templates/admin/partials/incident_drawer.html +++ b/enferno/admin/templates/admin/partials/incident_drawer.html @@ -2,7 +2,7 @@ v-model="incidentDrawer" clipped fixed - location="right" + location="end" temporary width="520" app @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/enferno/admin/templates/admin/partials/location_drawer.html b/enferno/admin/templates/admin/partials/location_drawer.html index c26831fd4..94980fb5e 100644 --- a/enferno/admin/templates/admin/partials/location_drawer.html +++ b/enferno/admin/templates/admin/partials/location_drawer.html @@ -2,7 +2,7 @@ v-model="locationDrawer" clipped fixed - location="right" + location="end" temporary width="520" app @@ -18,4 +18,4 @@ - \ No newline at end of file + diff --git a/enferno/admin/templates/admin/partials/user_drawer.html b/enferno/admin/templates/admin/partials/user_drawer.html index b6c44ada5..b098914ca 100644 --- a/enferno/admin/templates/admin/partials/user_drawer.html +++ b/enferno/admin/templates/admin/partials/user_drawer.html @@ -1,6 +1,6 @@ - \ No newline at end of file + diff --git a/enferno/admin/templates/admin/system-administration.html b/enferno/admin/templates/admin/system-administration.html index c6125575c..7b75db367 100644 --- a/enferno/admin/templates/admin/system-administration.html +++ b/enferno/admin/templates/admin/system-administration.html @@ -1041,7 +1041,7 @@

{{ _('Enable Mail System') }}

- - - - -