diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2023-08-19 14:30:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-19 14:30:04 -0700 |
commit | 19c783960eee7cbe912a60d1d67d4a613546c642 (patch) | |
tree | 78e3d5f0a9811796f3dee990e201366c4e9ea89c /modern | |
parent | 706b1a1cfb518b85eb5271f3e25a27dd4bd3a804 (diff) | |
parent | 67b57c189c6e43732d09018f669df87f4491be5a (diff) | |
download | trackermap-web-19c783960eee7cbe912a60d1d67d4a613546c642.tar.gz trackermap-web-19c783960eee7cbe912a60d1d67d4a613546c642.tar.bz2 trackermap-web-19c783960eee7cbe912a60d1d67d4a613546c642.zip |
Merge pull request #1164 from jguthrie100/add_country_flags
Add country flags to language select
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/common/components/LocalizationProvider.jsx | 115 | ||||
-rw-r--r-- | modern/src/login/LoginPage.jsx | 12 |
2 files changed, 68 insertions, 59 deletions
diff --git a/modern/src/common/components/LocalizationProvider.jsx b/modern/src/common/components/LocalizationProvider.jsx index 6bc64831..1c87bc7d 100644 --- a/modern/src/common/components/LocalizationProvider.jsx +++ b/modern/src/common/components/LocalizationProvider.jsx @@ -64,62 +64,62 @@ import zhTW from '../../resources/l10n/zh_TW.json'; import usePersistedState from '../util/usePersistedState'; const languages = { - af: { data: af, name: 'Afrikaans' }, - ar: { data: ar, name: 'العربية' }, - az: { data: az, name: 'Azərbaycanca' }, - bg: { data: bg, name: 'Български' }, - bn: { data: bn, name: 'বাংলা' }, - ca: { data: ca, name: 'Català' }, - cs: { data: cs, name: 'Čeština' }, - de: { data: de, name: 'Deutsch' }, - da: { data: da, name: 'Dansk' }, - el: { data: el, name: 'Ελληνικά' }, - en: { data: en, name: 'English' }, - es: { data: es, name: 'Español' }, - fa: { data: fa, name: 'فارسی' }, - fi: { data: fi, name: 'Suomi' }, - fr: { data: fr, name: 'Français' }, - gl: { data: gl, name: 'Galego' }, - he: { data: he, name: 'עברית' }, - hi: { data: hi, name: 'हिन्दी' }, - hr: { data: hr, name: 'Hrvatski' }, - hu: { data: hu, name: 'Magyar' }, - id: { data: id, name: 'Bahasa Indonesia' }, - it: { data: it, name: 'Italiano' }, - ja: { data: ja, name: '日本語' }, - ka: { data: ka, name: 'ქართული' }, - kk: { data: kk, name: 'Қазақша' }, - ko: { data: ko, name: '한국어' }, - km: { data: km, name: 'ភាសាខ្មែរ' }, - lo: { data: lo, name: 'ລາວ' }, - lt: { data: lt, name: 'Lietuvių' }, - lv: { data: lv, name: 'Latviešu' }, - ml: { data: ml, name: 'മലയാളം' }, - mn: { data: mn, name: 'Монгол хэл' }, - ms: { data: ms, name: 'بهاس ملايو' }, - nb: { data: nb, name: 'Norsk bokmål' }, - ne: { data: ne, name: 'नेपाली' }, - nl: { data: nl, name: 'Nederlands' }, - nn: { data: nn, name: 'Norsk nynorsk' }, - pl: { data: pl, name: 'Polski' }, - pt: { data: pt, name: 'Português' }, - ptBR: { data: ptBR, name: 'Português (Brasil)' }, - ro: { data: ro, name: 'Română' }, - ru: { data: ru, name: 'Русский' }, - si: { data: si, name: 'සිංහල' }, - sk: { data: sk, name: 'Slovenčina' }, - sl: { data: sl, name: 'Slovenščina' }, - sq: { data: sq, name: 'Shqipëria' }, - sr: { data: sr, name: 'Srpski' }, - sv: { data: sv, name: 'Svenska' }, - ta: { data: ta, name: 'தமிழ்' }, - th: { data: th, name: 'ไทย' }, - tr: { data: tr, name: 'Türkçe' }, - uk: { data: uk, name: 'Українська' }, - uz: { data: uz, name: 'Oʻzbekcha' }, - vi: { data: vi, name: 'Tiếng Việt' }, - zh: { data: zh, name: '中文' }, - zhTW: { data: zhTW, name: '中文 (Taiwan)' }, + af: { data: af, country: 'ZA', name: 'Afrikaans' }, + ar: { data: ar, country: 'AE', name: 'العربية' }, + az: { data: az, country: 'AZ', name: 'Azərbaycanca' }, + bg: { data: bg, country: 'BG', name: 'Български' }, + bn: { data: bn, country: 'IN', name: 'বাংলা' }, + ca: { data: ca, country: 'ES', name: 'Català' }, + cs: { data: cs, country: 'CZ', name: 'Čeština' }, + de: { data: de, country: 'DE', name: 'Deutsch' }, + da: { data: da, country: 'DK', name: 'Dansk' }, + el: { data: el, country: 'GR', name: 'Ελληνικά' }, + en: { data: en, country: 'US', name: 'English' }, + es: { data: es, country: 'ES', name: 'Español' }, + fa: { data: fa, country: 'IR', name: 'فارسی' }, + fi: { data: fi, country: 'FI', name: 'Suomi' }, + fr: { data: fr, country: 'FR', name: 'Français' }, + gl: { data: gl, country: 'ES', name: 'Galego' }, + he: { data: he, country: 'IL', name: 'עברית' }, + hi: { data: hi, country: 'IN', name: 'हिन्दी' }, + hr: { data: hr, country: 'HR', name: 'Hrvatski' }, + hu: { data: hu, country: 'HU', name: 'Magyar' }, + id: { data: id, country: 'ID', name: 'Bahasa Indonesia' }, + it: { data: it, country: 'IT', name: 'Italiano' }, + ja: { data: ja, country: 'JP', name: '日本語' }, + ka: { data: ka, country: 'GE', name: 'ქართული' }, + kk: { data: kk, country: 'KZ', name: 'Қазақша' }, + ko: { data: ko, country: 'KR', name: '한국어' }, + km: { data: km, country: 'KH', name: 'ភាសាខ្មែរ' }, + lo: { data: lo, country: 'LA', name: 'ລາວ' }, + lt: { data: lt, country: 'LT', name: 'Lietuvių' }, + lv: { data: lv, country: 'LV', name: 'Latviešu' }, + ml: { data: ml, country: 'IN', name: 'മലയാളം' }, + mn: { data: mn, country: 'MN', name: 'Монгол хэл' }, + ms: { data: ms, country: 'MY', name: 'بهاس ملايو' }, + nb: { data: nb, country: 'NO', name: 'Norsk bokmål' }, + ne: { data: ne, country: 'NP', name: 'नेपाली' }, + nl: { data: nl, country: 'NL', name: 'Nederlands' }, + nn: { data: nn, country: 'NO', name: 'Norsk nynorsk' }, + pl: { data: pl, country: 'PL', name: 'Polski' }, + pt: { data: pt, country: 'PT', name: 'Português' }, + ptBR: { data: ptBR, country: 'BR', name: 'Português (Brasil)' }, + ro: { data: ro, country: 'RO', name: 'Română' }, + ru: { data: ru, country: 'RU', name: 'Русский' }, + si: { data: si, country: 'LK', name: 'සිංහල' }, + sk: { data: sk, country: 'SK', name: 'Slovenčina' }, + sl: { data: sl, country: 'SI', name: 'Slovenščina' }, + sq: { data: sq, country: 'AL', name: 'Shqipëria' }, + sr: { data: sr, country: 'RS', name: 'Srpski' }, + sv: { data: sv, country: 'SE', name: 'Svenska' }, + ta: { data: ta, country: 'IN', name: 'தமிழ்' }, + th: { data: th, country: 'TH', name: 'ไทย' }, + tr: { data: tr, country: 'TR', name: 'Türkçe' }, + uk: { data: uk, country: 'UA', name: 'Українська' }, + uz: { data: uz, country: 'UZ', name: 'Oʻzbekcha' }, + vi: { data: vi, country: 'VN', name: 'Tiếng Việt' }, + zh: { data: zh, country: 'CN', name: '中文' }, + zhTW: { data: zhTW, country: 'TW', name: '中文 (Taiwan)' }, }; const getDefaultLanguage = () => { @@ -186,3 +186,6 @@ export const useTranslationKeys = (predicate) => { const { data } = context.languages[context.language]; return Object.keys(data).filter(predicate); }; + +export const getFlagEmoji = (country) => String.fromCodePoint(...[...country].map(x=>0x1f1a5+x.charCodeAt())); + diff --git a/modern/src/login/LoginPage.jsx b/modern/src/login/LoginPage.jsx index 54fd09fb..94321298 100644 --- a/modern/src/login/LoginPage.jsx +++ b/modern/src/login/LoginPage.jsx @@ -10,7 +10,7 @@ import { useTheme } from '@mui/material/styles'; import { useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import { sessionActions } from '../store'; -import { useLocalization, useTranslation } from '../common/components/LocalizationProvider'; +import { useLocalization, useTranslation, getFlagEmoji } from '../common/components/LocalizationProvider'; import LoginLayout from './LoginLayout'; import usePersistedState from '../common/util/usePersistedState'; import { handleLoginTokenListeners, nativeEnvironment, nativePostMessage } from '../common/components/NativeInterface'; @@ -50,7 +50,7 @@ const LoginPage = () => { const t = useTranslation(); const { languages, language, setLanguage } = useLocalization(); - const languageList = Object.entries(languages).map((values) => ({ code: values[0], name: values[1].name })); + const languageList = Object.entries(languages).map((values) => ({ code: values[0], country: values[1].country, name: values[1].name })); const [failed, setFailed] = useState(false); @@ -209,7 +209,13 @@ const LoginPage = () => { <FormControl fullWidth> <InputLabel>{t('loginLanguage')}</InputLabel> <Select label={t('loginLanguage')} value={language} onChange={(e) => setLanguage(e.target.value)}> - {languageList.map((it) => <MenuItem key={it.code} value={it.code}>{it.name}</MenuItem>)} + {languageList.map((it) => ( + <MenuItem key={it.code} value={it.code}> + {getFlagEmoji(it.country)} + + {it.name} + </MenuItem> + ))} </Select> </FormControl> )} |