From a1e963adf65f4edb352397a27d35c31e47ce2099 Mon Sep 17 00:00:00 2001 From: Jake Low Date: Tue, 29 Oct 2024 09:16:26 -0700 Subject: [PATCH] Simplify loading of localization strings --- lang/af.json | 20 -- lang/cs_CZ.json | 20 -- lang/de.json | 20 -- lang/en-US.json | 20 -- lang/es.json | 20 -- lang/fa_IR.json | 20 -- lang/fr.json | 20 -- lang/it_IT.json | 20 -- lang/ja.json | 20 -- lang/ko.json | 20 -- lang/nl.json | 20 -- lang/pl.json | 20 -- lang/pt_BR.json | 20 -- lang/pt_PT.json | 20 -- lang/ru_RU.json | 20 -- lang/sr.json | 20 -- lang/tr.json | 20 -- lang/uk.json | 20 -- lang/vi.json | 20 -- lang/zh_TW.json | 20 -- .../UserSettings/UserSettingsSchema.jsx | 7 +- src/services/User/Locale/Locale.js | 227 +++++------------- src/services/User/Locale/Messages.js | 87 ------- src/services/User/User.js | 3 +- 24 files changed, 65 insertions(+), 659 deletions(-) delete mode 100644 src/services/User/Locale/Messages.js diff --git a/lang/af.json b/lang/af.json index 42901b778..49055a7f0 100644 --- a/lang/af.json +++ b/lang/af.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Points", "Leaderboard.user.topChallenges": "Top Challenges", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/cs_CZ.json b/lang/cs_CZ.json index 14ab25877..b1b26b766 100644 --- a/lang/cs_CZ.json +++ b/lang/cs_CZ.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Body", "Leaderboard.user.topChallenges": "Top Challenges", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (ukrajinsky)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/de.json b/lang/de.json index bacc2ff3e..1ec599a19 100644 --- a/lang/de.json +++ b/lang/de.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Punkte", "Leaderboard.user.topChallenges": "Top-Kampagnen", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Tschechisch - Tschechische Republik)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persisch - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italienisch)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (niederländisch)", - "Locale.pl.label": "pl (polnisch)", - "Locale.pt-BR.label": "pt-BR (Brasilianisches Portugiesisch)", - "Locale.pt-PT.label": "pt-PT (Portugiesisch Portugal)", - "Locale.ru-RU.label": "ru-RU (Russisch - Russland)", - "Locale.sr.label": "sr (Serbisch)", - "Locale.tr.label": "tr (türkisch)", - "Locale.uk.label": "uk (Ukrainisch)", - "Locale.vi.label": "vi (Vietnamesisch)", - "Locale.zh-TW.label": "zh-TW (taiwanisch)", "Map.layerSelectionList.header": "Gewünschtes Merkmal auswählen", "Metrics.archived": "Archiviert", "Metrics.challenges": "Challenges", diff --git a/lang/en-US.json b/lang/en-US.json index a826772ca..690d9a7e4 100644 --- a/lang/en-US.json +++ b/lang/en-US.json @@ -1056,26 +1056,6 @@ "Leaderboard.user.points": "Points", "Leaderboard.user.topChallenges": "Top Challenges", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/es.json b/lang/es.json index 5192729f1..098ff408e 100644 --- a/lang/es.json +++ b/lang/es.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Puntos", "Leaderboard.user.topChallenges": "Principales desafíos", "Leaderboard.users.none": "No hay usuarios por período de tiempo", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Checo - República Checa)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persa - Irán)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Holandés)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Portugués brasileño)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Ruso-Rusia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turco)", - "Locale.uk.label": "uk (Ucraniano)", - "Locale.vi.label": "vi (Vietnamita)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Seleccione el elemento deseado", "Metrics.archived": "Archivado", "Metrics.challenges": "Desafíos", diff --git a/lang/fa_IR.json b/lang/fa_IR.json index 1c4888236..8dcef259f 100644 --- a/lang/fa_IR.json +++ b/lang/fa_IR.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Points", "Leaderboard.user.topChallenges": "Top Challenges", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/fr.json b/lang/fr.json index 70997589a..495dba037 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Points", "Leaderboard.user.topChallenges": "Top défis", "Leaderboard.users.none": "Aucun utilisateur pour cette période", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Tchèque - République Tchèque)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persan - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Néerlandais)", - "Locale.pl.label": "pl (Polonais)", - "Locale.pt-BR.label": "pt-BR (Portugais du Brésil)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russe - Russie)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turc)", - "Locale.uk.label": "uk (Ukrainien)", - "Locale.vi.label": "vt (Vietnamien)", - "Locale.zh-TW.label": "zh-TW (Chinois - Taïwan)", "Map.layerSelectionList.header": "Sélectionner la fonctionnalité souhaitée", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/it_IT.json b/lang/it_IT.json index 74295a844..8c3b24b8e 100644 --- a/lang/it_IT.json +++ b/lang/it_IT.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Punti", "Leaderboard.user.topChallenges": "Le migliori sfide", "Leaderboard.users.none": "Nessun utente per il periodo di tempo", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Tedesco)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Seleziona la funzione desiderata", "Metrics.archived": "Archiviato", "Metrics.challenges": "Sfide", diff --git a/lang/ja.json b/lang/ja.json index 1b0321aba..beb739751 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "ポイント", "Leaderboard.user.topChallenges": "トップチャレンジ", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/ko.json b/lang/ko.json index 7a949bf25..d837a0046 100644 --- a/lang/ko.json +++ b/lang/ko.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "점", "Leaderboard.user.topChallenges": "상위 도전", "Leaderboard.users.none": "해당 기간 동안 기여한 사용자가 없음", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (이탈리아어)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "원하는 기능 선택", "Metrics.archived": "아카이브", "Metrics.challenges": "챌린지", diff --git a/lang/nl.json b/lang/nl.json index 4e6a4d18b..583e4ae1c 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Punten", "Leaderboard.user.topChallenges": "Top-missies", "Leaderboard.users.none": "Geen deelnemers voor deze tijdperiode", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Tsjechisch - Tsjechische Republiek)", - "Locale.de.label": "de (Duits)", - "Locale.en-US.label": "en-US (U.S. Engels)", - "Locale.es.label": "es (Spaans)", - "Locale.fa-IR.label": "fa-IR (Perzisch - Iran)", - "Locale.fr.label": "fr (Frans)", - "Locale.it.label": "it (Italiaans)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Nederlands)", - "Locale.pl.label": "pl (Pools)", - "Locale.pt-BR.label": "pt-BR (Portugees Braziliaans)", - "Locale.pt-PT.label": "pt-PT (Portugees Portugal)", - "Locale.ru-RU.label": "ru-RU (Russisch - Rusland)", - "Locale.sr.label": "sr (Servisch)", - "Locale.tr.label": "tr (Turks)", - "Locale.uk.label": "uk (Oekraïns)", - "Locale.vi.label": "vi (Vietnamees)", - "Locale.zh-TW.label": "zh-TW (Chinees - Taiwan)", "Map.layerSelectionList.header": "Gewenste object selecteren", "Metrics.archived": "Gearchiveerd", "Metrics.challenges": "Missies", diff --git a/lang/pl.json b/lang/pl.json index 1e8972200..3697c15fa 100644 --- a/lang/pl.json +++ b/lang/pl.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Punkty", "Leaderboard.user.topChallenges": "Najpopularniejsze wyzwania", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (czeski)", - "Locale.de.label": "de (niemiecki)", - "Locale.en-US.label": "en-US (angielski - US)", - "Locale.es.label": "es (hiszpański)", - "Locale.fa-IR.label": "fa-IR (perski - Iran)", - "Locale.fr.label": "fr (francuski)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (japoński)", - "Locale.ko.label": "ko (koreański)", - "Locale.nl.label": "nl (holenderski)", - "Locale.pl.label": "pl (polski)", - "Locale.pt-BR.label": "pt-BR (portugalski - Brazylia)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (rosyjski)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (turecki)", - "Locale.uk.label": "uk (ukraiński)", - "Locale.vi.label": "vi (wietnamski)", - "Locale.zh-TW.label": "zh-TW (chiński - Tajwan)", "Map.layerSelectionList.header": "Wybierz żądaną funkcję", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/pt_BR.json b/lang/pt_BR.json index 751cd77a4..ba3a4eb43 100644 --- a/lang/pt_BR.json +++ b/lang/pt_BR.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Pontos", "Leaderboard.user.topChallenges": "Principais desafios", "Leaderboard.users.none": "Nenhum usuário por período de tempo", - "Locale.af.label": "af (Africâner)", - "Locale.cs-CZ.label": "cs-CZ (Tcheco - República Tcheca)", - "Locale.de.label": "de (Alemão)", - "Locale.en-US.label": "en-US (Inglês - EUA)", - "Locale.es.label": "es (Espanhol)", - "Locale.fa-IR.label": "fa-IR (Persa - Irã)", - "Locale.fr.label": "fr (Francês)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "já (Japonês)", - "Locale.ko.label": "ko (Coreano)", - "Locale.nl.label": "nl (Holandês)", - "Locale.pl.label": "pl (Polonês)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russo - Rússia)", - "Locale.sr.label": "sr (Sérvio)", - "Locale.tr.label": "tr (Turco)", - "Locale.uk.label": "uk (Ucraniano)", - "Locale.vi.label": "vi (Vietnamita)", - "Locale.zh-TW.label": "zh-TW (Chinês - Taiwan)", "Map.layerSelectionList.header": "Selecione o elemento desejado", "Metrics.archived": "Arquivado", "Metrics.challenges": "Desafios", diff --git a/lang/pt_PT.json b/lang/pt_PT.json index aff6b7325..1cda64064 100644 --- a/lang/pt_PT.json +++ b/lang/pt_PT.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Pontos", "Leaderboard.user.topChallenges": "Principais desafios", "Leaderboard.users.none": "Nenhum utilizador para o período de tempo", - "Locale.af.label": "af (africâner)", - "Locale.cs-CZ.label": "cs-CZ (checo - República Checa)", - "Locale.de.label": "de (alemão)", - "Locale.en-US.label": "en-US (inglês dos E.U.A.)", - "Locale.es.label": "es (espanhol)", - "Locale.fa-IR.label": "fa-IR (persa - Irão)", - "Locale.fr.label": "fr (francês)", - "Locale.it.label": "it (italiano)", - "Locale.ja.label": "ja (japonês)", - "Locale.ko.label": "ko (coreano)", - "Locale.nl.label": "nl (holandês)", - "Locale.pl.label": "pl (polaco)", - "Locale.pt-BR.label": "pt-BR (português do Brasil)", - "Locale.pt-PT.label": "pt-PT (português de Portugal)", - "Locale.ru-RU.label": "ru-RU (russo - Rússia)", - "Locale.sr.label": "sr (sérvio)", - "Locale.tr.label": "tr (turco)", - "Locale.uk.label": "uk (ucraniano)", - "Locale.vi.label": "vi (vietnamita)", - "Locale.zh-TW.label": "zh-TW (chinês - Taiwan)", "Map.layerSelectionList.header": "Selecione o elemento pretendido", "Metrics.archived": "Arquivado", "Metrics.challenges": "Desafios", diff --git a/lang/ru_RU.json b/lang/ru_RU.json index d0629b1d5..7310c4978 100644 --- a/lang/ru_RU.json +++ b/lang/ru_RU.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Очки", "Leaderboard.user.topChallenges": "Топ вызовов", "Leaderboard.users.none": "Нет пользователей в обозначенный период времени", - "Locale.af.label": "af (Африкаанс)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "нем (Немецкий)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Испанский)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Французский)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (Японский)", - "Locale.ko.label": "ko (Корейский)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "рус-РУС (Русский-Россия)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Украинский)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Вызовы", diff --git a/lang/sr.json b/lang/sr.json index 14269e876..6c50ece98 100644 --- a/lang/sr.json +++ b/lang/sr.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Поени", "Leaderboard.user.topChallenges": "Топ изазови", "Leaderboard.users.none": "Није било корисника за овај период", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Изабери жељене објекте", "Metrics.archived": "Архивирано", "Metrics.challenges": "Изазови", diff --git a/lang/tr.json b/lang/tr.json index 4d513fcdc..b64bdc486 100644 --- a/lang/tr.json +++ b/lang/tr.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Puanlar", "Leaderboard.user.topChallenges": "Popüler Görevler", "Leaderboard.users.none": "Zaman dilimi için kullanıcı yok", - "Locale.af.label": "af (Güney Afrika Hollanda lehçesi)", - "Locale.cs-CZ.label": "cs-CZ (Çek - Çek Cumhuriyeti)", - "Locale.de.label": "de (Almanca)", - "Locale.en-US.label": "en-US (ABD İngilizcesi)", - "Locale.es.label": "es (İspanyolca)", - "Locale.fa-IR.label": "fa-IR (Farsça - İran)", - "Locale.fr.label": "fr (Fransızca)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (Japonca)", - "Locale.ko.label": "ko (Korece)", - "Locale.nl.label": "nl (Flemenkçe)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Brezilya Portekizcesi)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Rusça - Rusya)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukraynaca)", - "Locale.vi.label": "vi (Vietnamca)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "İstediğiniz Özelliği Seçin", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/uk.json b/lang/uk.json index eced5ed4f..74d7afa0b 100644 --- a/lang/uk.json +++ b/lang/uk.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Бали", "Leaderboard.user.topChallenges": "Основні виклики", "Leaderboard.users.none": "Немає учасників за обраний період", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Česko - Česká republika)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (فارسی - ایران)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Русский - Россия)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Українська)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Оберіть потрібний елемент", "Metrics.archived": "Заархівовано", "Metrics.challenges": "Виклики", diff --git a/lang/vi.json b/lang/vi.json index f65b11e62..4602010fd 100644 --- a/lang/vi.json +++ b/lang/vi.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Points", "Leaderboard.user.topChallenges": "Top Challenges", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/lang/zh_TW.json b/lang/zh_TW.json index 4d663c433..f7f30fe4c 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -1052,26 +1052,6 @@ "Leaderboard.user.points": "Points", "Leaderboard.user.topChallenges": "Top Challenges", "Leaderboard.users.none": "No users for time period", - "Locale.af.label": "af (Afrikaans)", - "Locale.cs-CZ.label": "cs-CZ (Czech - Czech Republic)", - "Locale.de.label": "de (Deutsch)", - "Locale.en-US.label": "en-US (U.S. English)", - "Locale.es.label": "es (Español)", - "Locale.fa-IR.label": "fa-IR (Persian - Iran)", - "Locale.fr.label": "fr (Français)", - "Locale.it.label": "it (Italiano)", - "Locale.ja.label": "ja (日本語)", - "Locale.ko.label": "ko (한국어)", - "Locale.nl.label": "nl (Dutch)", - "Locale.pl.label": "pl (Polish)", - "Locale.pt-BR.label": "pt-BR (Português Brasileiro)", - "Locale.pt-PT.label": "pt-PT (Português Portugal)", - "Locale.ru-RU.label": "ru-RU (Russian - Russia)", - "Locale.sr.label": "sr (Српски)", - "Locale.tr.label": "tr (Turkish)", - "Locale.uk.label": "uk (Ukrainian)", - "Locale.vi.label": "vi (Vietnamese)", - "Locale.zh-TW.label": "zh-TW (Chinese - Taiwan)", "Map.layerSelectionList.header": "Select Desired Feature", "Metrics.archived": "Archived", "Metrics.challenges": "Challenges", diff --git a/src/pages/Profile/UserSettings/UserSettingsSchema.jsx b/src/pages/Profile/UserSettings/UserSettingsSchema.jsx index 81bc245c6..d958daf87 100644 --- a/src/pages/Profile/UserSettings/UserSettingsSchema.jsx +++ b/src/pages/Profile/UserSettings/UserSettingsSchema.jsx @@ -2,7 +2,7 @@ import _map from 'lodash/map' import _values from 'lodash/values' import _filter from 'lodash/filter' import AsManager from '../../../interactions/User/AsManager' -import { Locale, localeLabels, defaultLocale } +import { SUPPORTED_LOCALES, LOCALE_NAMES, defaultLocale } from '../../../services/User/Locale/Locale' import { Editor, editorLabels } from '../../../services/Editor/Editor' import { ChallengeBasemap, basemapLayerLabels } @@ -24,7 +24,6 @@ import messages from '../Messages' * @author [Neil Rotstan](https://github.com/nrotstan) */ export const jsSchema = (intl, user, editor) => { - const localizedLocaleLabels = localeLabels(intl) const localizedEditorLabels = editorLabels(intl) const localizedBasemapLabels = basemapLayerLabels(intl) @@ -78,8 +77,8 @@ export const jsSchema = (intl, user, editor) => { locale: { title: intl.formatMessage(messages.localeLabel), type: "string", - enum: _values(Locale), - enumNames: _map(Locale, value => localizedLocaleLabels[value]), + enum: SUPPORTED_LOCALES, + enumNames: SUPPORTED_LOCALES.map(locale => LOCALE_NAMES[locale]), default: defaultLocale(), }, defaultBasemap: { diff --git a/src/services/User/Locale/Locale.js b/src/services/User/Locale/Locale.js index 24aca879a..21fe74d70 100644 --- a/src/services/User/Locale/Locale.js +++ b/src/services/User/Locale/Locale.js @@ -1,147 +1,59 @@ -import "@formatjs/intl-relativetimeformat/polyfill"; -import _map from "lodash/map"; -import _isString from "lodash/isString"; -import _fromPairs from "lodash/fromPairs"; -import messages from "./Messages"; - -// To add support for a new locale, add it to both `Locale` and `LocaleImports` -// in this file, and then add a description of the new locale to the -// `Messages.js` file in this directory - -// Supported locales -export const unsortedLocale = { - enUS: "en-US", - es: "es", - fr: "fr", - de: "de", - it: "it", - af: "af", - ja: "ja", - ko: "ko", - nl: "nl", - "pt-BR": "pt-BR", - "pt-PT": "pt-PT", - "cs-CZ": "cs-CZ", - "fa-IR": "fa-IR", - "ru-RU": "ru-RU", - uk: "uk", - vi: "vi", - tr: "tr", - sr: "sr", - pl: "pl", - "zh-TW": "zh-TW" +// Functions which load translated strings for a particular language when called. +// It's important that (1) these aren't imported at the top level (we don't want +// to bloat the main bundle with all strings for every language) but also that +// the argument to the import() function is a literal string (so that our bundler +// can analyze it and include those assets in the output dist/ directory). +const LOCALE_LOADERS = { + "af": () => import("../../../../lang/af.json"), + "cs-CZ": () => import("../../../../lang/cs_CZ.json"), + "de": () => import("../../../../lang/de.json"), + "en-US": () => import("../../../../lang/en-US.json"), + "es": () => import("../../../../lang/es.json"), + "fa-IR": () => import("../../../../lang/fa_IR.json"), + "fr": () => import("../../../../lang/fr.json"), + "it": () => import("../../../../lang/it_IT.json"), + "ja": () => import("../../../../lang/ja.json"), + "ko": () => import("../../../../lang/ko.json"), + "nl": () => import("../../../../lang/nl.json"), + "pl": () => import("../../../../lang/pl.json"), + "pt-BR": () => import("../../../../lang/pt_BR.json"), + "pt-PT": () => import("../../../../lang/pt_PT.json"), + "ru-RU": () => import("../../../../lang/ru_RU.json"), + "sr": () => import("../../../../lang/sr.json"), + "tr": () => import("../../../../lang/tr.json"), + "uk": () => import("../../../../lang/uk.json"), + "vi": () => import("../../../../lang/vi.json"), + "zh-TW": () => import("../../../../lang/zh_TW.json"), }; -export const Locale = Object.freeze(Object.keys(unsortedLocale).sort().reduce( - (obj, key) => { - obj[key] = unsortedLocale[key]; - return obj; - }, - {} -)); +// Array of supported locale identifiers +export const SUPPORTED_LOCALES = Object.keys(LOCALE_LOADERS); -// Dynamic imports to load locale data and translation files -const LocaleImports = { - [Locale.enUS]: () => - Promise.all([ - import("../../../../lang/en-US.json"), - import("@formatjs/intl-relativetimeformat/locale-data/en"), - ]), - [Locale.es]: () => - Promise.all([ - import("../../../../lang/es.json"), - import("@formatjs/intl-relativetimeformat/locale-data/es"), - ]), - [Locale.fr]: () => - Promise.all([ - import("../../../../lang/fr.json"), - import("@formatjs/intl-relativetimeformat/locale-data/fr"), - ]), - [Locale.de]: () => - Promise.all([ - import("../../../../lang/de.json"), - import("@formatjs/intl-relativetimeformat/locale-data/de"), - ]), - [Locale.it]: () => - Promise.all([ - import("../../../../lang/it_IT.json"), - import("@formatjs/intl-relativetimeformat/locale-data/it"), - ]), - [Locale.af]: () => - Promise.all([ - import("../../../../lang/af.json"), - import("@formatjs/intl-relativetimeformat/locale-data/af"), - ]), - [Locale.ja]: () => - Promise.all([ - import("../../../../lang/ja.json"), - import("@formatjs/intl-relativetimeformat/locale-data/ja"), - ]), - [Locale.ko]: () => - Promise.all([ - import("../../../../lang/ko.json"), - import("@formatjs/intl-relativetimeformat/locale-data/ko"), - ]), - [Locale.nl]: () => - Promise.all([ - import("../../../../lang/nl.json"), - import("@formatjs/intl-relativetimeformat/locale-data/nl"), - ]), - [Locale.uk]: () => - Promise.all([ - import("../../../../lang/uk.json"), - import("@formatjs/intl-relativetimeformat/locale-data/uk"), - ]), - [Locale.vi]: () => - Promise.all([ - import("../../../../lang/vi.json"), - import("@formatjs/intl-relativetimeformat/locale-data/vi"), - ]), - [Locale["pt-BR"]]: () => - Promise.all([ - import("../../../../lang/pt_BR.json"), - import("@formatjs/intl-relativetimeformat/locale-data/pt"), - ]), - [Locale["pt-PT"]]: () => - Promise.all([ - import("../../../../lang/pt_PT.json"), - import("@formatjs/intl-relativetimeformat/locale-data/pt"), - ]), - [Locale["cs-CZ"]]: () => - Promise.all([ - import("../../../../lang/cs_CZ.json"), - import("@formatjs/intl-relativetimeformat/locale-data/cs"), - ]), - [Locale["fa-IR"]]: () => - Promise.all([ - import("../../../../lang/fa_IR.json"), - import("@formatjs/intl-relativetimeformat/locale-data/fa"), - ]), - [Locale["ru-RU"]]: () => - Promise.all([ - import("../../../../lang/ru_RU.json"), - import("@formatjs/intl-relativetimeformat/locale-data/ru"), - ]), - [Locale.tr]: () => - Promise.all([ - import("../../../../lang/tr.json"), - import("@formatjs/intl-relativetimeformat/locale-data/tr"), - ]), - [Locale.sr]: () => - Promise.all([ - import("../../../../lang/sr.json"), - import("@formatjs/intl-relativetimeformat/locale-data/sr"), - ]), - [Locale.pl]: () => - Promise.all([ - import("../../../../lang/pl.json"), - import("@formatjs/intl-relativetimeformat/locale-data/pl"), - ]), - [Locale["zh-TW"]]: () => - Promise.all([ - import("../../../../lang/zh_TW.json"), - import("@formatjs/intl-relativetimeformat/locale-data/zh"), - ]), +// Locale names are shown in the language picker alongside the ISO codes. These +// are intentionally NOT localized, so that if a user is "stuck" in a language +// they don't understand, they'll still be able to recognize their own language +// in this list. +export const LOCALE_NAMES = { + "af": "Afrikaans", + "cs-CZ": "Čeština", + "de": "Deutsch", + "en-US": "English (U.S.)", + "es": "Español", + "fa-IR": "فارسی", + "fr": "Français", + "it": "Italiano", + "ja": "日本語", + "ko": "한국어", + "nl": "Nederlands", + "pl": "Polski", + "pt-BR": "Português Brasileiro", + "pt-PT": "Português Portugal", + "ru-RU": "Русский", + "sr": "Српски", + "tr": "Türkçe", + "uk": "Українська", + "vi": "tiếng Việt", + "zh-TW": "國語", }; /** @@ -149,7 +61,7 @@ const LocaleImports = { * otherwise. */ export const isSupportedLocale = function (locale) { - return _isString(locale) && _isString(Locale[locale]); + return SUPPORTED_LOCALES.includes(locale); }; /** @@ -160,35 +72,18 @@ export const loadTranslatedMessages = async function (locale) { locale = defaultLocale(); } - const [messages] = await LocaleImports[locale](); - return messages.default; + // load the locale data asynchronously + const loader = LOCALE_LOADERS[locale]; + const module = await loader(); + // loader returns a module, the JSON data is in its default export + return module.default; }; /** - * Returns the default locale configured in the .env file, or U.S. English if + * Returns the default locale configured in the .env file, or U.S. English if * no default is configured or if the configured locale isn't supported. */ export const defaultLocale = function () { const configured = window.env.REACT_APP_DEFAULT_LOCALE; - - return isSupportedLocale(configured) ? configured : Locale.enUS; + return isSupportedLocale(configured) ? configured : Locales["en-US"]; }; - -/** - * Returns an object mapping label messages for locale values to raw - * internationalized messages suitable for use with FormattedMessage or - * formatMessage. - * - * > Note that these are the messages for the locale labels themselves (like - * > 'U.S. English' for en-US or 'Spanish' for es), not to be confused with - * > translated messages for a locale. - */ -export const labelMessagesByLocale = _fromPairs( - _map(messages, (message, key) => [Locale[key], message]) -); - -/** Returns object containing localized labels */ -export const localeLabels = (intl) => - _fromPairs( - _map(messages, (message, key) => [key, intl.formatMessage(message)]) - ); diff --git a/src/services/User/Locale/Messages.js b/src/services/User/Locale/Messages.js deleted file mode 100644 index 834dbf362..000000000 --- a/src/services/User/Locale/Messages.js +++ /dev/null @@ -1,87 +0,0 @@ -import { defineMessages } from "react-intl"; - -/** - * Internationalized messages for use with Locale - */ -export default defineMessages({ - "en-US": { - id: "Locale.en-US.label", - defaultMessage: "en-US (U.S. English)", - }, - es: { - id: "Locale.es.label", - defaultMessage: "es (Español)", - }, - de: { - id: "Locale.de.label", - defaultMessage: "de (Deutsch)", - }, - it: { - id: "Locale.it.label", - defaultMessage: "it (Italiano)", - }, - fr: { - id: "Locale.fr.label", - defaultMessage: "fr (Français)", - }, - af: { - id: "Locale.af.label", - defaultMessage: "af (Afrikaans)", - }, - ja: { - id: "Locale.ja.label", - defaultMessage: "ja (日本語)", - }, - ko: { - id: "Locale.ko.label", - defaultMessage: "ko (한국어)", - }, - nl: { - id: "Locale.nl.label", - defaultMessage: "nl (Dutch)", - }, - "pt-BR": { - id: "Locale.pt-BR.label", - defaultMessage: "pt-BR (Português Brasileiro)", - }, - "pt-PT": { - id: "Locale.pt-PT.label", - defaultMessage: "pt-PT (Português Portugal)", - }, - "fa-IR": { - id: "Locale.fa-IR.label", - defaultMessage: "fa-IR (Persian - Iran)", - }, - "cs-CZ": { - id: "Locale.cs-CZ.label", - defaultMessage: "cs-CZ (Czech - Czech Republic)", - }, - "ru-RU": { - id: "Locale.ru-RU.label", - defaultMessage: "ru-RU (Russian - Russia)", - }, - uk: { - id: "Locale.uk.label", - defaultMessage: "uk (Ukrainian)", - }, - vi: { - id: "Locale.vi.label", - defaultMessage: "vi (Vietnamese)", - }, - tr: { - id: "Locale.tr.label", - defaultMessage: "tr (Turkish)", - }, - sr: { - id: "Locale.sr.label", - defaultMessage: "sr (Српски)", - }, - pl: { - id: "Locale.pl.label", - defaultMessage: "pl (Polish)", - }, - "zh-TW": { - id: "Locale.zh-TW.label", - defaultMessage: "zh-TW (Chinese - Taiwan)", - }, -}); diff --git a/src/services/User/User.js b/src/services/User/User.js index 52b522f38..8cd4781c1 100644 --- a/src/services/User/User.js +++ b/src/services/User/User.js @@ -21,7 +21,6 @@ import { resetCache } from '../Server/RequestCache' import Endpoint from '../Server/Endpoint' import RequestStatus from '../Server/RequestStatus' import genericEntityReducer from '../Server/GenericEntityReducer' -import { Locale } from './Locale/Locale' import { challengeSchema, receiveChallenges, fetchChallenges } from '../Challenge/Challenge' import { taskSchema, @@ -988,7 +987,7 @@ const reduceUsersFurther = function(mergedState, oldState, userEntities) { // Normalize server's default `en` locale to `en-US` if (_get(entity, 'settings.locale') === 'en') { - mergedState[entity.id].settings.locale = Locale.enUS + mergedState[entity.id].settings.locale = "en-US" } } }