appwrite/app/init/locales.php

24 lines
679 B
PHP
Raw Normal View History

2025-03-15 11:00:36 +00:00
<?php
use Utopia\Config\Config;
use Utopia\Locale\Locale;
Locale::$exceptions = false;
$locales = Config::getParam('locale-codes', []);
foreach ($locales as $locale) {
$code = $locale['code'];
2025-03-15 13:17:47 +00:00
$path = __DIR__ . '/../config/locale/translations/' . $code . '.json';
2025-03-15 11:00:36 +00:00
if (!\file_exists($path)) {
2025-03-15 13:17:47 +00:00
$path = __DIR__ . '/../config/locale/translations/' . \substr($code, 0, 2) . '.json'; // if `ar-ae` doesn't exist, look for `ar`
2025-03-15 11:00:36 +00:00
if (!\file_exists($path)) {
2025-03-15 13:17:47 +00:00
$path = __DIR__ . '/../config/locale/translations/en.json'; // if none translation exists, use default from `en.json`
2025-03-15 11:00:36 +00:00
}
}
Locale::setLanguageFromJSON($code, $path);
}