diff --git a/src/components/compose.jsx b/src/components/compose.jsx index ba5ad7c4..17d4c43b 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -1439,10 +1439,10 @@ function Compose({ code, fallback: common, }); - const same = commonText === native; + const showCommon = commonText !== native; return ( ); })} @@ -1452,10 +1452,10 @@ function Compose({ code, fallback: common, }); - const same = commonText === native; + const showCommon = commonText !== native; return ( ); })} diff --git a/src/components/lang-selector.jsx b/src/components/lang-selector.jsx index 801e4962..e0ab202a 100644 --- a/src/components/lang-selector.jsx +++ b/src/components/lang-selector.jsx @@ -1,4 +1,5 @@ import { useLingui } from '@lingui/react'; +import { useMemo } from 'preact/hooks'; import { DEFAULT_LANG, LOCALES } from '../locales'; import { activateLang } from '../utils/lang'; @@ -7,6 +8,28 @@ import localeCode2Text from '../utils/localeCode2Text'; export default function LangSelector() { const { i18n } = useLingui(); + const populatedLocales = useMemo(() => { + return LOCALES.map((lang) => { + const native = localeCode2Text({ code: lang, locale: lang }); + const common = localeCode2Text(lang); + const showCommon = !!common && common !== native; + return { + code: lang, + native, + common, + showCommon, + }; + }).sort((a, b) => { + // If pseudo-LOCALE, always put it at the bottom + if (a.code === 'pseudo-LOCALE') return 1; + if (b.code === 'pseudo-LOCALE') return -1; + // Sort by code + if (a.code < b.code) return -1; + if (a.code > b.code) return 1; + return 0; + }); + }, [i18n.locale]); + return (