GitHub user dosubot[bot] added a comment to the discussion: /superset/language_pack/zh/
<!-- Answer --> Superset 6.0 的嵌入式仪表盘如果还在请求 /superset/language_pack/zh/,通常说明前端没有正确获取到 bootstrap 里的语言包数据,或者 locale 配置和语言包文件夹名不一致,导致前端 fallback 到动态请求接口(这在 6.0+ 已经废弃)[参考](https://github.com/apache/superset/discussions/34885)。 你可以这样排查和修复: 1. **superset_config.py 里加 locale override** 有时 Superset 后端传给前端的 locale 是 'zh',但实际语言包文件夹是 'zh_CN' 或 'zh_TW',导致找不到。可以用 override 函数强制 locale 和语言包一致: ```python from superset.translations.utils import get_language_pack def override_bootstrap_locale(data): if data.get("locale") == "zh": data["locale"] = "zh" data["language_pack"] = get_language_pack("zh") return data COMMON_BOOTSTRAP_OVERRIDES_FUNC = override_bootstrap_locale ``` 如果你用的是 'zh_CN' 或 'zh_TW',把上面 "zh" 换成对应的 locale。 2. **重建前端语言包** 进入 superset-frontend 目录,执行 ``` npm run build-translation ``` 然后重启 Superset 服务。 3. **确保 initialBootstrapData 正确传递** 你的 embedDashboard 配置已经传递了 `initialBootstrapData: { common: { locale: 'zh' } }`,但如果前端包没同步或 locale 不匹配,还是会 fallback 到接口请求。 4. **彻底清理缓存和旧前端包** 确保没有老的前端构建缓存,浏览器和服务器都清理一下。 5. **确认 superset-frontend 代码和 superset_config.py 都是 6.0+ 的标准实现** 避免有自定义或老版本代码路径。 如果这样配置后,嵌入式页面依然请求 /superset/language_pack/zh/,可以在 override_bootstrap_locale 里加 print/log,确认函数被调用,且 data["language_pack"] 正确注入。这样前端就不会再请求接口,而是直接用 bootstrap 里的语言包数据,嵌入式页面就能正常显示中文了。[参考](https://github.com/apache/superset/discussions/33594#discussioncomment-13290644) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/696121a9-c583-4e14-938a-4e349aadd478?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)& nbsp;[](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35864) GitHub link: https://github.com/apache/superset/discussions/35864#discussioncomment-14799855 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
