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 49b583bef8e0a65a9c940517252bcfee94dd6310
Author: aurelie.ehanno <[email protected]>
AuthorDate: Fri May 13 15:13:19 2022 -0400

    fix : add locale to activate french translation for DatePicker component
---
 .../controls/DateFilterControl/components/CustomFrame.tsx      | 10 ++++++++++
 1 file changed, 10 insertions(+)

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 48637f36e3..c457ccfc3c 100644
--- 
a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx
+++ 
b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx
@@ -41,9 +41,16 @@ import {
   CustomRangeKey,
   FrameComponentProps,
 } from 'src/explore/components/controls/DateFilterControl/types';
+import { bootstrapData } from 'src/preamble';
+import localeFR from 'antd/es/date-picker/locale/fr_FR';
+import localeEN from 'antd/es/date-picker/locale/en_US';
 
 export function CustomFrame(props: FrameComponentProps) {
   const { customRange, matchedFlag } = customTimeRangeDecode(props.value);
+  let locale = localeEN;
+  if (bootstrapData.common.locale === 'fr') {
+    locale = localeFR;
+  }
   if (!matchedFlag) {
     props.onChange(customTimeRangeEncode(customRange));
   }
@@ -132,6 +139,7 @@ export function CustomFrame(props: FrameComponentProps) {
                   onChange('sinceDatetime', datetime.format(MOMENT_FORMAT))
                 }
                 allowClear={false}
+                locale={locale}
               />
             </Row>
           )}
@@ -184,6 +192,7 @@ export function CustomFrame(props: FrameComponentProps) {
                   onChange('untilDatetime', datetime.format(MOMENT_FORMAT))
                 }
                 allowClear={false}
+                locale={locale}
               />
             </Row>
           )}
@@ -241,6 +250,7 @@ export function CustomFrame(props: FrameComponentProps) {
                   }
                   allowClear={false}
                   className="control-anchor-to-datetime"
+                  locale={locale}
                 />
               </Col>
             )}

Reply via email to