cdmikechen edited a comment on issue #8749: AddSliceContainer.jsx can't be 
translated by messages.json 
URL: 
https://github.com/apache/incubator-superset/issues/8749#issuecomment-562438922
 
 
   Finally found the cause of the problem~
   1. In `superset/assets/src/preamble.js` superset must get document id `app` 
to set `@superset-ui/translation` config. But  `AddSliceContainer.jsx` replace 
id `app` to `js-add-slice-container`.
   2. In `superset/views/core.py` web response must contain 
`bootstrap_data.common` node, so that `superset/assets/src/preamble.js` can 
read translation messages.
   ```
   "common": self.common_bootstrap_payload(),
   ```
   But `/chart/add` response data doesn't have this node.
   ```python
           return self.render_template(
               "superset/add_slice.html",
               bootstrap_data=json.dumps(
                   {"datasources": sorted(datasources, key=lambda d: d["label"])
               ),
           )
   ```
   We need to add this element like this:
   ```python
           messages = get_flashed_messages(with_categories=True)
           locale = str(get_locale())
           common_bootstrap = {
               "flash_messages": messages,
               "conf": {k: conf.get(k) for k in FRONTEND_CONF_KEYS},
               "locale": locale,
               "language_pack": get_language_pack(locale),
               "feature_flags": get_feature_flags(),
           }
   
           return self.render_template(
               "superset/add_slice.html",
               bootstrap_data=json.dumps(
                   {"datasources": sorted(datasources, key=lambda d: 
d["label"]),
                    "common": common_bootstrap}
               ),
           )
   ```
   
   If I can, I think I will take some time to fix this problem by a PR recently

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to