From f249437af24142c275fb9e6ab733a378cd2dab3f Mon Sep 17 00:00:00 2001 From: Maxim Leshchenko Date: Sat, 11 Dec 2021 16:27:40 +0200 Subject: [PATCH] L10n: Add the ability to specify a fallback locale for locales --- Web/Util/Localizator.php | 2 +- locales/ru_old.strings | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Web/Util/Localizator.php b/Web/Util/Localizator.php index d73bec13..fb25b370 100644 --- a/Web/Util/Localizator.php +++ b/Web/Util/Localizator.php @@ -57,7 +57,7 @@ class Localizator $lang = is_null($lang) ? static::DEFAULT_LANG : $lang; $array = @self::parse(dirname(__FILE__) . "/../../locales/$lang.strings"); - return $array[$id] ?? "@$id"; + return $array[$id] ?? (!empty($array["__fallback"]) ? $this->_($id, $array["__fallback"]) : "@$id"); } function export($lang = NULL): ?array diff --git a/locales/ru_old.strings b/locales/ru_old.strings index 863b43d4..fc75d230 100644 --- a/locales/ru_old.strings +++ b/locales/ru_old.strings @@ -1,5 +1,6 @@ "__locale" = "ru_UA.utf8;ru_RU.UTF-8;Rus"; "__WinEncoding" = "Windows-1251"; +"__fallback" = "ru"; /* Check for https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html */