diff --git a/app/init.php b/app/init.php index b7cbd97a3b..ce319213d6 100644 --- a/app/init.php +++ b/app/init.php @@ -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 diff --git a/tests/e2e/Services/Locale/LocaleBase.php b/tests/e2e/Services/Locale/LocaleBase.php index 64b5e5f43e..dc4a2347c6 100644 --- a/tests/e2e/Services/Locale/LocaleBase.php +++ b/tests/e2e/Services/Locale/LocaleBase.php @@ -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) {