mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
use default for missing locales
This commit is contained in:
+6
-4
@@ -666,15 +666,17 @@ $locales = Config::getParam('locale-codes', []);
|
||||
|
||||
foreach ($locales as $locale) {
|
||||
$code = $locale['code'];
|
||||
|
||||
$path = __DIR__ . '/config/locale/translations/' . $code . '.json';
|
||||
|
||||
if (!\file_exists($path)) {
|
||||
$path = __DIR__ . '/config/locale/translations/' . \substr($code, 0, 2) . '.json';
|
||||
$path = __DIR__ . '/config/locale/translations/' . \substr($code, 0, 2) . '.json'; // if `ar-ae` doesn't exist, look for `ar`
|
||||
if(!\file_exists($path)) {
|
||||
$path = __DIR__ . '/config/locale/translations/en.json'; // if none translation exists, use default from `en.json`
|
||||
}
|
||||
}
|
||||
|
||||
if (\file_exists($path)) {
|
||||
Locale::setLanguageFromJSON($code, $path);
|
||||
}
|
||||
Locale::setLanguageFromJSON($code, $path);
|
||||
}
|
||||
|
||||
\stream_context_set_default([ // Set global user agent and http settings
|
||||
|
||||
@@ -235,7 +235,7 @@ trait LocaleBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/countries', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-locale' => $lang,
|
||||
'x-appwrite-locale' => $lang['code'],
|
||||
]);
|
||||
|
||||
if (!\is_array($response['body']['countries'])) {
|
||||
@@ -243,7 +243,7 @@ trait LocaleBase
|
||||
}
|
||||
|
||||
foreach ($response['body']['countries'] as $i => $code) {
|
||||
$this->assertContains($code['code'], $defaultCountries, $code['code'] . ' country should be removed from ' . $lang);
|
||||
$this->assertContains($code['code'], $defaultCountries, $code['code'] . ' country should be removed from ' . $lang['code']);
|
||||
}
|
||||
|
||||
// foreach (array_keys($defaultCountries) as $i => $code) {
|
||||
@@ -256,11 +256,11 @@ trait LocaleBase
|
||||
$response = $this->client->call(Client::METHOD_GET, '/locale/continents', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-locale' => $lang,
|
||||
'x-appwrite-locale' => $lang['code'],
|
||||
]);
|
||||
|
||||
foreach ($response['body']['continents'] as $i => $code) {
|
||||
$this->assertContains($code['code'], $defaultContinents, $code['code'] . ' continent should be removed from ' . $lang);
|
||||
$this->assertContains($code['code'], $defaultContinents, $code['code'] . ' continent should be removed from ' . $lang['code']);
|
||||
}
|
||||
|
||||
// foreach (array_keys($defaultContinents) as $i => $code) {
|
||||
|
||||
Reference in New Issue
Block a user