Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix(web): preserve exact locale matching in resolver

Tinb9eae212cda8
diff --git a/apps/web/src/lib/i18n/index.ts b/apps/web/src/lib/i18n/index.ts
index 48d444c1f..8c63a3a5d 100644
--- a/apps/web/src/lib/i18n/index.ts
+++ b/apps/web/src/lib/i18n/index.ts
@@ -15,13 +15,15 @@ export function resolveLocale(
preferredLocale?: string | null,
browserLocale?: string | null,
): AppLocale {
- const candidates = [preferredLocale, browserLocale]
- .filter(Boolean)
- .map((value) => value?.toLowerCase());
+ const candidates = [preferredLocale, browserLocale].filter(
+ (value): value is string => Boolean(value),
+ );
for (const candidate of candidates) {
- if (!candidate) continue;
- const exactMatch = supportedLocales.find((locale) => locale === candidate);
+ const normalizedCandidate = candidate.toLowerCase();
+ const exactMatch = supportedLocales.find(
+ (locale) => locale.toLowerCase() === normalizedCandidate,
+ );
if (exactMatch) return exactMatch;
const languageMatch = supportedLocales.find(