aboutsummaryrefslogtreecommitdiff
path: root/modern/src/common
diff options
context:
space:
mode:
authorJamie Guthrie <jamie.guthrie@gmail.com>2023-08-19 23:26:59 +0200
committerJamie Guthrie <jamie.guthrie@gmail.com>2023-08-19 23:26:59 +0200
commit92dfd50188886beb3f6498ce019cd380795fc126 (patch)
treebb74fea24fd9a8ff37a9e680a8808d9db3bb96ed /modern/src/common
parentc2402bac156703bc5d80fd6c166cafefcb435b1a (diff)
downloadtrackermap-web-92dfd50188886beb3f6498ce019cd380795fc126.tar.gz
trackermap-web-92dfd50188886beb3f6498ce019cd380795fc126.tar.bz2
trackermap-web-92dfd50188886beb3f6498ce019cd380795fc126.zip
Switch countryCode to country & refactor method
Diffstat (limited to 'modern/src/common')
-rw-r--r--modern/src/common/components/LocalizationProvider.jsx121
1 files changed, 58 insertions, 63 deletions
diff --git a/modern/src/common/components/LocalizationProvider.jsx b/modern/src/common/components/LocalizationProvider.jsx
index a6a14859..0010b381 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, countryCode: 'ZA', name: 'Afrikaans' },
- ar: { data: ar, countryCode: 'AE', name: 'العربية' },
- az: { data: az, countryCode: 'AZ', name: 'Azərbaycanca' },
- bg: { data: bg, countryCode: 'BG', name: 'Български' },
- bn: { data: bn, countryCode: 'IN', name: 'বাংলা' },
- ca: { data: ca, countryCode: 'ES', name: 'Català' },
- cs: { data: cs, countryCode: 'CZ', name: 'Čeština' },
- de: { data: de, countryCode: 'DE', name: 'Deutsch' },
- da: { data: da, countryCode: 'DK', name: 'Dansk' },
- el: { data: el, countryCode: 'GR', name: 'Ελληνικά' },
- en: { data: en, countryCode: 'US', name: 'English' },
- es: { data: es, countryCode: 'ES', name: 'Español' },
- fa: { data: fa, countryCode: 'IR', name: 'فارسی' },
- fi: { data: fi, countryCode: 'FI', name: 'Suomi' },
- fr: { data: fr, countryCode: 'FR', name: 'Français' },
- gl: { data: gl, countryCode: 'ES', name: 'Galego' },
- he: { data: he, countryCode: 'IL', name: 'עברית' },
- hi: { data: hi, countryCode: 'IN', name: 'हिन्दी' },
- hr: { data: hr, countryCode: 'HR', name: 'Hrvatski' },
- hu: { data: hu, countryCode: 'HU', name: 'Magyar' },
- id: { data: id, countryCode: 'ID', name: 'Bahasa Indonesia' },
- it: { data: it, countryCode: 'IT', name: 'Italiano' },
- ja: { data: ja, countryCode: 'JP', name: '日本語' },
- ka: { data: ka, countryCode: 'GE', name: 'ქართული' },
- kk: { data: kk, countryCode: 'KZ', name: 'Қазақша' },
- ko: { data: ko, countryCode: 'KR', name: '한국어' },
- km: { data: km, countryCode: 'KH', name: 'ភាសាខ្មែរ' },
- lo: { data: lo, countryCode: 'LA', name: 'ລາວ' },
- lt: { data: lt, countryCode: 'LT', name: 'Lietuvių' },
- lv: { data: lv, countryCode: 'LV', name: 'Latviešu' },
- ml: { data: ml, countryCode: 'IN', name: 'മലയാളം' },
- mn: { data: mn, countryCode: 'MN', name: 'Монгол хэл' },
- ms: { data: ms, countryCode: 'MY', name: 'بهاس ملايو' },
- ne: { data: ne, countryCode: 'NP', name: 'नेपाली' },
- nl: { data: nl, countryCode: 'NL', name: 'Nederlands' },
- nb: { data: nb, countryCode: 'NO', name: 'Norsk bokmål' },
- nn: { data: nn, countryCode: 'NO', name: 'Norsk nynorsk' },
- pl: { data: pl, countryCode: 'PL', name: 'Polski' },
- pt: { data: pt, countryCode: 'PT', name: 'Português' },
- ptBR: { data: ptBR, countryCode: 'BR', name: 'Português (Brasil)' },
- ro: { data: ro, countryCode: 'RO', name: 'Română' },
- ru: { data: ru, countryCode: 'RU', name: 'Русский' },
- si: { data: si, countryCode: 'LK', name: 'සිංහල' },
- sk: { data: sk, countryCode: 'SK', name: 'Slovenčina' },
- sl: { data: sl, countryCode: 'SI', name: 'Slovenščina' },
- sq: { data: sq, countryCode: 'AL', name: 'Shqipëria' },
- sr: { data: sr, countryCode: 'RS', name: 'Srpski' },
- sv: { data: sv, countryCode: 'SE', name: 'Svenska' },
- ta: { data: ta, countryCode: 'IN', name: 'தமிழ்' },
- th: { data: th, countryCode: 'TH', name: 'ไทย' },
- tr: { data: tr, countryCode: 'TR', name: 'Türkçe' },
- uk: { data: uk, countryCode: 'UA', name: 'Українська' },
- uz: { data: uz, countryCode: 'UZ', name: 'Oʻzbekcha' },
- vi: { data: vi, countryCode: 'VN', name: 'Tiếng Việt' },
- zh: { data: zh, countryCode: 'CN', name: '中文' },
- zhTW: { data: zhTW, countryCode: 'TW', 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: 'بهاس ملايو' },
+ ne: { data: ne, country: 'NP', name: 'नेपाली' },
+ nl: { data: nl, country: 'NL', name: 'Nederlands' },
+ nb: { data: nb, country: 'NO', name: 'Norsk bokmål' },
+ 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 = () => {
@@ -187,10 +187,5 @@ export const useTranslationKeys = (predicate) => {
return Object.keys(data).filter(predicate);
};
-export const getFlagEmoji = (countryCode) => {
- const codePoints = countryCode
- .toUpperCase()
- .split('')
- .map((char) => 127397 + char.charCodeAt());
- return String.fromCodePoint(...codePoints);
-};
+export const getFlagEmoji = (country) => String.fromCodePoint(...[...country].map(x=>0x1f1a5+x.charCodeAt()));
+