L10n: Add the ability to specify a fallback locale for locales

This commit is contained in:
Maxim Leshchenko 2021-12-11 16:27:40 +02:00
parent 6fca87bc3f
commit f249437af2
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
2 changed files with 2 additions and 1 deletions

View file

@ -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

View file

@ -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 */