Skip to content

Commit

Permalink
fix: en translations not displayed in default string api when en is n…
Browse files Browse the repository at this point in the history
…ot default (#50)
  • Loading branch information
imorland authored Jan 10, 2025
1 parent 2dd913a commit 81d9055
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Repositories/DefaultStringsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,18 @@ public function getTranslation($key)

protected function localeKeys(): array
{
// Retrieve the list of locale keys
$locales = array_keys($this->manager->getLocales());

// Always include English, even if the language pack has been disabled or removed
// This is necessary to show translations that aren't included in any of the currently enabled langue packs
// The absence of the language pack doesn't cause any issue, all translations from core and its extensions are not in the language pack anyway
if (!in_array('en', $locales)) {
if (!in_array('en', $locales, true)) {
$locales[] = 'en';
}

return $locales;
// Ensure that en is always the first locale
// This is nessesary to show "ref" strings correctly when en is not the default language
return array_merge(['en'], array_diff($locales, ['en']));
}
}

0 comments on commit 81d9055

Please sign in to comment.