diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md index 7323d9a9b49..a1bd1b0ca9e 100644 --- a/CHANGELOG-WIP.md +++ b/CHANGELOG-WIP.md @@ -9,3 +9,6 @@ ### Extensibility - Added `craft\web\ErrorHandler::exceptionAsArray()`. - Added `craft\web\ErrorHandler::showExceptionDetails()`. + +### System +- Craft now calls `setlocale()` based on the target language, so that `SORT_LOCALE_STRING` behaves as expected. ([#14509](https://github.com/craftcms/cms/issues/14509), [#14513](https://github.com/craftcms/cms/pull/14513)) diff --git a/src/base/ApplicationTrait.php b/src/base/ApplicationTrait.php index 086faf1ec3a..68c2fad9c8f 100644 --- a/src/base/ApplicationTrait.php +++ b/src/base/ApplicationTrait.php @@ -342,6 +342,12 @@ public function updateTargetLanguage(?bool $useUserLanguage = null): void } $this->language = $this->getTargetLanguage($useUserLanguage); + setlocale( + LC_COLLATE, + str_replace('-', '_', $this->language), // target language + 'C.UTF-8', // libc >= 2.13 + 'C.utf8' // different spelling + ); $this->_gettingLanguage = false; }