Skip to content

Commit e3cf434

Browse files
authored
Bugfix: Fix regression in language codes (#2215)
* Use Locales instead of Languages * Rename locales to match ISO-standard * Add upgrade note
1 parent bdd5a50 commit e3cf434

4 files changed

Lines changed: 12 additions & 9 deletions

File tree

config/config.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ $config = [
824824
*/
825825
'language.available' => [
826826
'en', 'no', 'nn', 'se', 'da', 'de', 'sv', 'fi', 'es', 'ca', 'fr', 'it', 'nl', 'lb',
827-
'cs', 'sk', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt-br', 'tr', 'ja', 'zh', 'zh-tw',
827+
'cs', 'sk', 'sl', 'lt', 'hr', 'hu', 'pl', 'pt', 'pt_BR', 'tr', 'ja', 'zh', 'zh_TW',
828828
'ru', 'et', 'he', 'id', 'sr', 'lv', 'ro', 'eu', 'el', 'af', 'zu', 'xh', 'st',
829829
],
830830
'language.rtl' => ['ar', 'dv', 'fa', 'ur', 'he'],

docs/simplesamlphp-upgrade-notes-2.3.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ The following properties were marked `deprecated` and will be removed in a next
3232

3333
## BC break
3434

35-
Plain-text admin-passwords are no longer allowed.
36-
Please use the `bin/pwgen.php` script to generate a secure password hash.
35+
- Plain-text admin-passwords are no longer allowed.
36+
Please use the `bin/pwgen.php` script to generate a secure password hash.
37+
38+
- The language codes `pt-br` and `zh-tw` have been renamed to `pt_BR` and `zh_TW`.
39+
Please update your configuration to match the new names.

src/SimpleSAML/Locale/Language.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace SimpleSAML\Locale;
1212

1313
use SimpleSAML\{Configuration, Logger, Utils};
14-
use Symfony\Component\Intl\Languages;
14+
use Symfony\Component\Intl\Locales;
1515

1616
use function array_fill_keys;
1717
use function array_key_exists;
@@ -114,7 +114,7 @@ public function __construct(
114114
/**
115115
* Filter configured (available) languages against installed languages.
116116
*
117-
* @return string[] The set of languages both in 'language.available' and Languages::getNames().
117+
* @return string[] The set of languages both in 'language.available' and Locales::getNames().
118118
*/
119119
private function getInstalledLanguages(): array
120120
{
@@ -124,7 +124,7 @@ private function getInstalledLanguages(): array
124124
);
125125
$availableLanguages = [];
126126
foreach ($configuredAvailableLanguages as $code) {
127-
if (Languages::exists($code)) {
127+
if (Locales::exists($code)) {
128128
$availableLanguages[] = $code;
129129
} else {
130130
Logger::error("Language \"$code\" not installed. Check config.");
@@ -219,8 +219,8 @@ public function getLanguage(): string
219219
*/
220220
public function getLanguageLocalizedName(string $code): ?string
221221
{
222-
if (Languages::exists($code)) {
223-
return Languages::getName($code);
222+
if (Locales::exists($code)) {
223+
return Locales::getName($code);
224224
}
225225
Logger::error("Name for language \"$code\" not found. Check config.");
226226
return null;

src/SimpleSAML/Locale/Localization.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Gettext\Loader\{MoLoader, PoLoader};
1616
use Gettext\{Translations, Translator, TranslatorFunctions};
1717
use SimpleSAML\{Configuration, Logger};
18-
use Symfony\Component\HttpFoundation\File\File;
1918
use SimpleSAML\Locale\Translate;
19+
use Symfony\Component\HttpFoundation\File\File;
2020

2121
use function explode;
2222
use function is_dir;

0 commit comments

Comments
 (0)