question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AddSliceContainer.jsx can't be translated by messages.json

See original GitHub issue

A clear and concise description of what the bug is.

Expected results

AddSliceContainer.jsx can be translated

Actual results

All other pages can be translated correctly, except AddSliceContainer.jsx cannot.

Screenshots

No.

How to reproduce the bug

I run a development flask and dev-server in my computer to test translation. I found that AddSliceContainer.jsx can not be translated well, meanwhile other pages can be translated correctly.

Environment

  • superset version: 0.35 and 0.34
  • python version: 3.7
  • node.js version: v10.16.0
  • npm version: 6.9.0

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven’t found one similar.

Additional context

No.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cdmikechencommented, Dec 6, 2019

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.

        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:

        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

0reactions
chengkaishengcommented, May 15, 2020

It helps. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AddSliceContainer.jsx can't be translated by messages.json
I run a development flask and dev-server in my computer to test translation. I found that AddSliceContainer.jsx can not be translated well, ...
Read more >
react-i18next not loading json translation files in React app ...
I'm not sure where you put the locale files, but I see two issues: You have specified a relative URL so you load...
Read more >
[incubator-superset] 07/08: Fixed korean translation error ...
This is an automated email from the ASF dual-hosted git repository. villebro pushed a commit to branch 0.34 in repository ...
Read more >
How to translate your React app with react-intl / FormatJS
Tutorial with a complete example on react translations. ... This is not required for the en.json because these messages are already contained in...
Read more >
How to Add Localization (l10n) to Your React App with react ...
You can add additional JSON files with the same keys and translated values for each desired language. Whatever language is set will determine ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found