Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: en translations not displayed in default string api when en is not default #50

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']));
}
}
Loading