cdmikechen commented on a change in pull request #13020:
URL: https://github.com/apache/superset/pull/13020#discussion_r572926571



##########
File path: superset/views/base.py
##########
@@ -327,6 +329,17 @@ def common_bootstrap_payload() -> Dict[str, Any]:
     }
 
 
+def get_moment_locale(locale):
+    moment_locale = locale
+    if "_" in moment_locale:
+        moment_locale = moment_locale.split("_")[0]
+
+    flag = conf.get("LANGUAGES").get(locale).get("flag")

Review comment:
       @ktmud  
   `humanize` and `moment.js` and `superset` use different locale keys. I 
didn't add variables by myself, so I only get variables in the current 
`LANGUAGES` config.
   Do we need to expand the current `LANGUAGES` config? Just like this:
   ```python
   LANGUAGES = {
       "en": {"flag": "us", "name": "English", "moment_locale": "en", 
"humanize_locale": "en", "d3_time_locale": "en-US"},
       "it": {"flag": "it", "name": "Italian", "moment_locale": "it", 
"humanize_locale": "en", "d3_time_locale": "it-IT"},
       "fr": {"flag": "fr", "name": "French", "moment_locale": "fr", 
"humanize_locale": "fr_FR", "d3_time_locale": "fr-FR"},
       "zh": {"flag": "cn", "name": "Chinese", "moment_locale": "zh-cn", 
"humanize_locale": "zh_CN", "d3_time_locale": "zh-CN"},
       "ja": {"flag": "jp", "name": "Japanese", "moment_locale": "ja", 
"humanize_locale": "jp", "d3_time_locale": "ja-JP"},
       "de": {"flag": "de", "name": "German", "moment_locale": "de", 
"humanize_locale": "de_DE", "d3_time_locale": "de-DE"},
       "pt": {"flag": "pt", "name": "Portuguese", "moment_locale": "pt", 
"humanize_locale": "en", "d3_time_locale": "en-US"},
       "pt_BR": {"flag": "br", "name": "Brazilian Portuguese", "moment_locale": 
"pt-br", "humanize_locale": "pt_BR", "d3_time_locale": "pt-BR"},
       "ru": {"flag": "ru", "name": "Russian", "moment_locale": "ru", 
"humanize_locale": "ru_RU", "d3_time_locale": "ru-RU"},
       "ko": {"flag": "kr", "name": "Korean", "moment_locale": "ko", 
"humanize_locale": "ko_KR", "d3_time_locale": "ko-KR"},
   }
   ```
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to