Localize language names

This commit is contained in:
Christian Schmidt 2024-12-26 20:04:32 +01:00
parent 8770905186
commit d79a75c3cc
2 changed files with 13 additions and 2 deletions

View File

@ -38,7 +38,7 @@ class TranslateButton extends PureComponent {
if (translation) {
const language = preloadedLanguages.find(lang => lang[0] === translation.get('detected_source_language'));
const languageName = language ? language[2] : translation.get('detected_source_language');
const languageName = language ? language[1] : translation.get('detected_source_language');
const provider = translation.get('provider');
return (

View File

@ -115,11 +115,22 @@ export const trendsAsLanding = getMeta('trends_as_landing_page');
export const useBlurhash = getMeta('use_blurhash');
export const usePendingItems = getMeta('use_pending_items');
export const version = getMeta('version');
export const languages = initialState?.languages;
export const criticalUpdatesPending = initialState?.critical_updates_pending;
export const statusPageUrl = getMeta('status_page_url');
export const sso_redirect = getMeta('sso_redirect');
export const termsOfServiceEnabled = getMeta('terms_of_service_enabled');
const displayNames = new Intl.DisplayNames(getMeta('locale'), {
type: 'language',
fallback: 'none',
languageDisplay: 'standard',
});
export const languages = initialState?.languages?.map(lang => {
// zh-YUE is not a valid CLDR unicode_language_id
return [lang[0], displayNames.of(lang[0].replace('zh-YUE', 'yue')) || lang[1], lang[2]];
});
/**
* @returns {string | undefined}
*/