You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/12/06 05:32:44 UTC

[GitHub] [incubator-superset] cdmikechen commented on issue #8749: AddSliceContainer.jsx can't be translated by messages.json

cdmikechen commented 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}
               ),
           )
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org