Skip to content

Commit e4f3700

Browse files
committed
Language resolution patch.
Changelog excerpt: - Ensure language resolution produces the correct capitalisation (e.g., xx-XX or xx-Xxxx).
1 parent f9a8d89 commit e4f3700

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,4 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
196196
### v3.7.2
197197

198198
- [2026.01.09]: Slightly improved the PDF handler's stream detection.
199+
- [2026.03.20]: Ensure language resolution produces the correct capitalisation (e.g., xx-XX or xx-Xxxx).

src/Loader.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: The loader (last modified: 2026.03.18).
11+
* This file: The loader (last modified: 2026.03.20).
1212
*/
1313

1414
namespace phpMussel\Core;
@@ -638,13 +638,26 @@ public function loadL10N(string $Path = ''): void
638638
$Accepted = '';
639639
foreach ($Try as $Accepted) {
640640
$Accepted = \preg_replace(['~;.*$~', '~[^-A-Za-z]|-$~'], '', $Accepted);
641+
if (\strpos($Accepted, '-') === false) {
642+
$Main = '';
643+
$Accepted = \strtolower($Accepted);
644+
} else {
645+
$Main = \strtolower(\preg_replace('~-.*$~', '', $Accepted));
646+
$Sub = \preg_replace('~^.*-~', '', $Accepted);
647+
$SubLen = \strlen($Sub);
648+
if ($SubLen === 4) {
649+
$Sub = \ucfirst(\strtolower($Sub));
650+
} elseif ($SubLen === 2) {
651+
$Sub = \strtoupper($Sub);
652+
}
653+
$Accepted = $Main . '-' . $Sub;
654+
}
641655
$Primary = '';
642656
$IsSameAs = false;
643657
if ($this->L10NAccepted === $Accepted) {
644658
$IsSameAs = true;
645659
break;
646660
}
647-
$Main = \strpos($Accepted, '-') === false ? '' : \strtolower(\preg_replace('~-.*$~', '', $Accepted));
648661
if (($Primary = $this->readFile($Path . $Accepted . '.yml')) !== '' || ($Primary = $this->readFile($Path . $Main . '.yml')) !== '') {
649662
break;
650663
}

0 commit comments

Comments
 (0)