You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by yo...@apache.org on 2022/09/03 04:36:33 UTC

[superset] 03/08: fix : add mapping between locales of superset and antd locales

This is an automated email from the ASF dual-hosted git repository.

yongjiezhao pushed a commit to branch add-translation-for-DatePicker
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 33357b99f0e4b0bd38a6cd2d2a8ab54a8bf39ad7
Author: aurelie.ehanno <au...@kosmos.fr>
AuthorDate: Fri May 20 15:47:47 2022 -0400

    fix : add mapping between locales of superset and antd locales
---
 .../DateFilterControl/components/CustomFrame.tsx   | 34 ++++++++++++++--------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx
index edcecc5069..2d1ad05886 100644
--- a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx
+++ b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx
@@ -44,20 +44,30 @@ import {
 import { locales } from 'antd/dist/antd-with-locales';
 import { bootstrapData } from '../../../../../preamble';
 
+const languages = {
+  en: 'en_US',
+  fr: 'fr_FR',
+  es: 'es_ES',
+  it: 'it_IT',
+  zh: 'zh_CN',
+  ja: 'ja_JP',
+  de: 'de_DE',
+  pt: 'pt_PT',
+  pt_BR: 'pt_BR',
+  ru: 'ru_RU',
+  ko: 'ko_KR',
+  sk: 'sk_SK',
+  sl: 'sl_SI',
+  nl: 'nl_NL',
+};
+
 export function CustomFrame(props: FrameComponentProps) {
-  let localeFiltrer = locales.en_US;
-  // There are two locale with 'fr', one for France and one for Belgium so for the moment by default we take France
-  // TODO : Once the correction is done on antd, we have to remove the if
-  if (bootstrapData.common.locale === 'fr') {
-    localeFiltrer = locales.fr_FR.DatePicker;
-  } else {
-    for (const locale in locales) {
-      if (locales[locale].locale === bootstrapData.common.locale) {
-        localeFiltrer = locales[locale].DatePicker;
-        break;
-      }
-    }
+  let localLanguage = languages[bootstrapData.common.locale];
+  if (localLanguage == null) {
+    localLanguage = 'en_US';
   }
+  const localeFiltrer = locales[localLanguage].DatePicker;
+
   const { customRange, matchedFlag } = customTimeRangeDecode(props.value);
   if (!matchedFlag) {
     props.onChange(customTimeRangeEncode(customRange));