Features: 1) Updated Russian translations for UI terms like "Dashboard" → "Панель", "Blogposts" → "Посты", etc.; 2) Added support for multiple locale directories in LOCALE_PATHS; 3) Introduced LANGUAGE_URL_OVERRIDES for URL language normalization.

Fixes: 1) Fixed case sensitivity in region code normalization (lowercase regions); 2) Corrected translation file updates to match new string values.

Extra: 1) Refactored middleware to normalize language codes to lowercase; 2) Added new locale paths for engine modules; 3) Improved consistency in translation keys and fallbacks.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-11-16 00:52:39 +03:00
parent 65002671cf
commit efa21cf9c0
4 changed files with 17 additions and 7 deletions

View file

@ -235,7 +235,7 @@ msgstr "Меню"
#: evibes/settings/unfold.py:67 #: evibes/settings/unfold.py:67
msgid "Dashboard" msgid "Dashboard"
msgstr "Приборная панель" msgstr "Панель"
#: evibes/settings/unfold.py:72 #: evibes/settings/unfold.py:72
msgid "Health" msgid "Health"
@ -255,7 +255,7 @@ msgstr "Группы"
#: evibes/settings/unfold.py:92 #: evibes/settings/unfold.py:92
msgid "Products" msgid "Products"
msgstr "Продукция" msgstr "Товары"
#: evibes/settings/unfold.py:97 #: evibes/settings/unfold.py:97
msgid "Categories" msgid "Categories"
@ -267,15 +267,15 @@ msgstr "Бренды"
#: evibes/settings/unfold.py:107 #: evibes/settings/unfold.py:107
msgid "Blogposts" msgid "Blogposts"
msgstr "Записи в блогах" msgstr "Посты"
#: evibes/settings/unfold.py:112 #: evibes/settings/unfold.py:112
msgid "Periodic Tasks" msgid "Periodic Tasks"
msgstr "Периодические задания" msgstr "Периодические задачи"
#: evibes/settings/unfold.py:137 #: evibes/settings/unfold.py:137
msgid "Taskboard" msgid "Taskboard"
msgstr "Доска задач" msgstr "Канбан"
#: evibes/settings/unfold.py:142 #: evibes/settings/unfold.py:142
msgid "Support" msgid "Support"

View file

@ -31,10 +31,10 @@ class CustomLocaleMiddleware(LocaleMiddleware):
parts = lang.replace("_", "-").split("-") parts = lang.replace("_", "-").split("-")
if len(parts) == 2: if len(parts) == 2:
lang_code = parts[0].lower() lang_code = parts[0].lower()
region = parts[1].upper() region = parts[1].lower()
normalized = f"{lang_code}-{region}" normalized = f"{lang_code}-{region}"
else: else:
normalized = lang normalized = lang.lower()
translation.activate(normalized) translation.activate(normalized)
request.LANGUAGE_CODE = normalized request.LANGUAGE_CODE = normalized

View file

@ -211,6 +211,14 @@ TEMPLATES: list[dict[str, str | list[str | Path] | dict[str, str | list[str]] |
USE_I18N: bool = True USE_I18N: bool = True
LOCALE_PATHS: tuple[Path, ...] = (
(BASE_DIR / "evibes/locale"),
(BASE_DIR / "engine/blog/locale"),
(BASE_DIR / "engine/core/locale"),
(BASE_DIR / "engine/payments/locale"),
(BASE_DIR / "engine/vibes_auth/locale"),
)
LANGUAGES: tuple[tuple[str, str], ...] = ( LANGUAGES: tuple[tuple[str, str], ...] = (
("ar-ar", "العربية"), ("ar-ar", "العربية"),
("cs-cz", "Česky"), ("cs-cz", "Česky"),
@ -301,6 +309,8 @@ CURRENCIES_WITH_SYMBOLS: tuple[tuple[str, str], ...] = (
("VND", ""), ("VND", ""),
) )
LANGUAGE_URL_OVERRIDES: dict[str, str] = {code.split("-")[0]: code for code, _ in LANGUAGES if "-" in code}
CURRENCY_CODE: str = dict(CURRENCIES_BY_LANGUAGES).get(LANGUAGE_CODE) # type: ignore[assignment] CURRENCY_CODE: str = dict(CURRENCIES_BY_LANGUAGES).get(LANGUAGE_CODE) # type: ignore[assignment]
MODELTRANSLATION_FALLBACK_LANGUAGES: tuple[str, ...] = (LANGUAGE_CODE, "en-us", "de-de") MODELTRANSLATION_FALLBACK_LANGUAGES: tuple[str, ...] = (LANGUAGE_CODE, "en-us", "de-de")