Skip to content

Commit 60eb866

Browse files
committed
fix(web): translate settings search titles, keep Traditional Chinese off Simplified, retry failed locale loads
1 parent ad75b05 commit 60eb866

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

‎apps/web/src/components/settings/SettingsSidebarNav.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
355355
<SettingsSectionIcon to={item.to} />
356356
<span className="min-w-0 flex-1">
357357
<span className="block truncate text-sm font-medium text-sidebar-foreground">
358-
{item.title}
358+
{m(item.title)}
359359
</span>
360360
<span className="block truncate text-2xs text-sidebar-muted-foreground/75">
361361
{m(SETTINGS_SECTION_LABELS[item.to])}

‎apps/web/src/i18n/locales.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ export function nativeLanguageName(locale: string): string {
1515
return NATIVE_LANGUAGE_NAMES[locale] ?? locale;
1616
}
1717

18+
// Our `zh` is Simplified, so Traditional tags only match an exact locale.
19+
const TRADITIONAL_CHINESE = /^zh[-_](hant|tw|hk|mo)\b/;
20+
1821
function matchSupportedLocale(tag: string): string | undefined {
1922
const normalized = tag.trim().toLowerCase();
2023
const language = normalized.split(/[-_]/)[0];
21-
return (
22-
SUPPORTED_LOCALES.find((locale) => locale.toLowerCase() === normalized) ??
23-
SUPPORTED_LOCALES.find((locale) => locale.toLowerCase() === language)
24-
);
24+
const exact = SUPPORTED_LOCALES.find((locale) => locale.toLowerCase() === normalized);
25+
if (exact || TRADITIONAL_CHINESE.test(normalized)) return exact;
26+
return SUPPORTED_LOCALES.find((locale) => locale.toLowerCase() === language);
2527
}
2628

2729
/** Saved setting to active locale; "system" and unknown values follow the host's languages. */

‎apps/web/src/i18n/runtime.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ function loadLocale(locale: string): Promise<void> {
2525
if (locale in loadedTranslations) return Promise.resolve();
2626
let load = pendingLoads.get(locale);
2727
if (!load) {
28-
// A failed load resolves without an entry, so the locale renders the English source.
28+
// A failed load resolves without an entry: English renders now and the next request retries.
2929
load = getTranslationsSnapshot(locale).then((loaded) => {
30-
loadedTranslations[locale] = loaded[locale] ?? {};
3130
pendingLoads.delete(locale);
31+
const translations = loaded[locale];
32+
if (translations) loadedTranslations[locale] = translations;
3233
});
3334
pendingLoads.set(locale, load);
3435
}

0 commit comments

Comments
 (0)