diff --git a/app/javascript/mastodon/components/status_content.jsx b/app/javascript/mastodon/components/status_content.jsx index 6b06b938de..aa8b060384 100644 --- a/app/javascript/mastodon/components/status_content.jsx +++ b/app/javascript/mastodon/components/status_content.jsx @@ -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 ( diff --git a/app/javascript/mastodon/initial_state.js b/app/javascript/mastodon/initial_state.js index 0c59fc9ee0..ea11eb7193 100644 --- a/app/javascript/mastodon/initial_state.js +++ b/app/javascript/mastodon/initial_state.js @@ -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} */