Skip to content

Commit

Permalink
Merge pull request #40808 from c39cfbb3/patch-3
Browse files Browse the repository at this point in the history
fix(L10N): Support "Accept-Language: zh-Hans-CN" and alike
  • Loading branch information
susnux authored Oct 18, 2023
2 parents 1d9d3b6 + 1bf15da commit 1f8c21a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/private/L10N/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,14 @@ private function getLanguageFromRequest(?string $app = null): string {
[$preferred_language] = explode(';', $preference);
$preferred_language = str_replace('-', '_', $preferred_language);

$preferred_language_parts = explode('_', $preferred_language);
foreach ($available as $available_language) {
if ($preferred_language === strtolower($available_language)) {
return $this->respectDefaultLanguage($app, $available_language);
}
if ($preferred_language_parts[0].'_'.end($preferred_language_parts) === strtolower($available_language)) {
return $available_language;
}
}

// Fallback from de_De to de
Expand Down

0 comments on commit 1f8c21a

Please sign in to comment.