Compare commits

...

3 Commits

Author SHA1 Message Date
Wendelin
d37e8e0183 Improve 2025-11-06 08:39:03 +01:00
Wendelin
a86d868baa Also add current lang as fallback 2025-11-05 16:34:21 +01:00
Wendelin
29e8edcb70 Language picker add search fallback to en 2025-11-05 16:23:50 +01:00

View File

@@ -22,6 +22,7 @@ export const getLanguageOptions = (
): PickerComboBoxItem[] => {
let options: PickerComboBoxItem[] = [];
const enLocale = { language: "en" } as FrontendLocaleData;
if (nativeName) {
const translations = translationMetadata.translations;
options = languages.map((lang) => {
@@ -37,18 +38,38 @@ export const getLanguageOptions = (
primary = lang;
}
}
let searchLabels = primary;
const browserLangName = formatLanguageCode(
lang,
locale || ({ language: navigator.language } as FrontendLocaleData)
);
if (browserLangName !== primary) {
searchLabels += `;${browserLangName}`;
}
const englishName = formatLanguageCode(lang, enLocale);
if (englishName !== primary && englishName !== browserLangName) {
searchLabels += `;${englishName}`;
}
return {
id: lang,
primary,
search_labels: [primary],
search_labels: searchLabels.split(";"),
};
});
} else if (locale) {
options = languages.map((lang) => ({
id: lang,
primary: formatLanguageCode(lang, locale),
search_labels: [formatLanguageCode(lang, locale)],
}));
options = languages.map((lang) => {
const primary = formatLanguageCode(lang, locale);
let searchLabels = primary;
const englishName = formatLanguageCode(lang, enLocale);
if (englishName !== primary) {
searchLabels += `;${englishName}`;
}
return {
id: lang,
primary,
search_labels: searchLabels.split(";"),
};
});
}
if (!noSort && locale) {