You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "jiderox (via GitHub)" <gi...@apache.org> on 2025/10/28 03:00:26 UTC

[D] /superset/language_pack/zh/ [superset]

GitHub user jiderox created a discussion: /superset/language_pack/zh/

在superset本身的界面显示中文是好的,但是在嵌入界面中请求这个接口的时候是不通的,报302状态码重定向到了登录界面。这种问题应该怎么做才能是中文接口正常登录

GitHub link: https://github.com/apache/superset/discussions/35864

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "jiderox (via GitHub)" <gi...@apache.org>.
GitHub user jiderox added a comment to the discussion: /superset/language_pack/zh/

<img width="665" height="765" alt="image" src="https://github.com/user-attachments/assets/369bf55d-548a-4244-ad7d-8a4fba1f65a3" />
superset本身的界面翻译是正常的,但是嵌入界面的翻译还是不行,
<img width="510" height="626" alt="image" src="https://github.com/user-attachments/assets/3273ac48-875b-4096-8296-c0622186eb6f" />
我的配置文件
# superset_config.py

# -------------------------------
# FEATURE FLAGS
# -------------------------------
FEATURE_FLAGS = {
    # 启用嵌入式 Superset Dashboard
    "EMBEDDED_SUPERSET": True,
    # 启用 Dashboard 原生过滤器
    "DASHBOARD_NATIVE_FILTERS": True,
    "DASHBOARD_RBAC": True,
}

# -------------------------------
# Guest Token 配置
# -------------------------------
# 定义可用于 Guest Token 的角色
GUEST_ROLE_NAME="Viewer"

# -------------------------------
# CSRF 配置
# -------------------------------
# 如果嵌入页面通过 API 调用 Guest Token,可以关闭 CSRF
WTF_CSRF_ENABLED = False

# -------------------------------
# X-Frame-Options / CSP 配置
# -------------------------------

# -------------------------------
# 代理修复(可选)
# -------------------------------
# 如果通过 Nginx 或其他反向代理访问,需要启用
ENABLE_PROXY_FIX = True

# -------------------------------
# 示例数据和加载配置
# -------------------------------
# 是否加载示例数据
LOAD_EXAMPLES = False
# 设置默认语言为中文
# ---------------------
# 🌐 多语言设置
# ---------------------
BABEL_DEFAULT_LOCALE = "zh"
#PUBLIC_ROUTES = ['language_pack']
BABEL_DEFAULT_FOLDER = "superset/translations"

LANGUAGES = {
    "zh": {"flag": "cn", "name": "简体中文"},
    "en": {"flag": "us", "name": "English"},
}
ENABLE_GUEST_TOKEN = True

GUEST_TOKEN_JWT_SECRET = "Xy7L9FvG3k8sDqH0u2b5M1aJz4TqYwPn"
GUEST_TOKEN_JWT_EXP_SECONDS = 3600
GUEST_TOKEN_JWT_AUDIENCE = "superset"
import logging
from superset.translations.utils import get_language_pack

# 初始化 logger
logger = logging.getLogger(__name__)

def override_bootstrap_locale(data):
    logger.warning("[DEBUG] override_bootstrap_locale called")

    current_locale = data.get("locale")
    logger.warning(f"[DEBUG] 当前语言环境: {current_locale}")

    # 判断语言环境
    if current_locale in ["zh", "zh_CN", "zh_Hans"]:
        try:
            lang_pack = get_language_pack("zh")
            data["locale"] = "zh"
            data["language_pack"] = lang_pack
            logger.warning(f"language_pack 内容示例: {list(data['language_pack'].items())[:100]}")
            logger.warning(f"[DEBUG] ✅ 已注入中文语言包,共 {len(lang_pack)} 条翻译。")
            # 👇 这里加中文确认信息
            logger.warning("🌏 Superset 已加载中文语言包,嵌入式页面将显示中文。")
        except Exception as e:
            logger.error(f"[DEBUG] ❌ 注入中文语言包失败: {e}")
    else:
        logger.warning("[DEBUG] Locale 非中文,跳过语言包注入。")

    return data

# 绑定函数
COMMON_BOOTSTRAP_OVERRIDES_FUNC = override_bootstrap_locale
-----------
[root@DMACC2 LC_MESSAGES]# ll
total 836
-rw-rw-r--. 1 azureuser azureuser 313627 Oct 28 07:31 messages.json
-rw-rw-r--. 1 azureuser azureuser 200593 Oct 28 07:55 messages.mo
-rw-r--r--. 1 azureuser azureuser 338039 Oct 27 09:07 messages.po
[root@DMACC2 LC_MESSAGES]# pwd
/data/superset/superset/translations/zh/LC_MESSAGES
这个目录下的编译文件也是好的

GitHub link: https://github.com/apache/superset/discussions/35864#discussioncomment-14802329

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: /superset/language_pack/zh/

<!-- Greeting -->
Hi @jiderox! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.

<!-- Answer -->
你遇到的 302 跳转到登录页,是因为 /superset/language_pack/zh/ 这个接口默认需要认证,嵌入式场景下没有有效的登录态或 session,所以会被 Flask AppBuilder 重定向到登录页(302)[参考](https://github.com/apache/superset/discussions/35099#discussioncomment-14370512)。

Superset 6.0 之后,语言包已经不再通过 /superset/language_pack/ 接口动态加载,而是直接打包进前端的 bootstrap 数据,页面初始化时自动注入,不再需要单独请求接口[参考](https://github.com/apache/superset/discussions/34885)。如果你的嵌入式页面还在请求 /superset/language_pack/zh/,建议:

1. 检查你的 Superset 版本和前端代码,确保用的是官方标准的 6.0+ 版本,不要再通过接口动态加载语言包。
2. 如果有自定义代码或老版本逻辑,请升级或调整,改为直接用 bootstrap 里的语言包数据。
3. 如果确实需要接口方式,必须保证嵌入页面有有效的 Superset 登录态(比如通过 guest token 认证),否则所有受保护接口都会 302 跳转[参考](https://github.com/apache/superset/discussions/35099#discussioncomment-14370512)。

总之,推荐升级到标准用法,避免再请求 /superset/language_pack/zh/,这样嵌入式页面就能正常显示中文,无需额外认证处理。


<!-- 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/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/8eb08746-b598-4def-b57b-5224a0d33f20?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](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-14799636

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on 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?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=696121a9-c583-4e14-938a-4e349aadd478) [![Learn about superset with Dosu](https://img.shields.io/badge/Learn%20about%20superset%20with%20Dosu-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODYiIGhlaWdodD0iODkiIHZpZXdCb3g9IjAgMCA4NiA4OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNS4yOTIzNiAxMi43OTI4TDE3Ljc1OTMgNi42ODE4OFY3Mi41NjY3TDUuMjkyMzYgODQuMDYxOFYxMi43OTI4WiIgZmlsbD0iI0I0QkI5MSIvPjxwYXRoIGQ9Ik0xOC4yNTc1IDczLjExOTZMNTkuMTMyOSA3Mi43NDhMNTEuNzAxMSA4Mi40MDk1TDI5LjAzMzggODYuMjkxTDYuMjM5NjIgODUuMTU1NEwxOC4yNTc1IDczLjExOTZaIiBmaWxsPSIjNzc4NTYxIi8%2BPHBhdGggZD0iTTE3LjQ5MTYgMy43MzYzM0wzLjU4NTU3IDEyLjcwOTlWODMuNTc5MkMzLjU4NTU3IDg0Ljc1NDIgNC4
 5ODU2MyA4NS4zNjUyIDUuODQ3MDUgODQuNTY2TDE5LjYyOTYgNzEuNzgwMSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjQyODQ0IiBzdHJva2UtbGluZWNhcD0icm91bmQiLz48bWFzayBpZD0iZG9zdS1kLWN1dG91dCIgZmlsbD0id2hpdGUiPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNDAuNzA0IDAuNTE4MDY2SDE3LjA0MzlWNzYuMjIyMUg0MC43MDRINDIuNTgwNUg0Ny44MDEzQzY4LjcwNjQgNzYuMjIyMSA4NS42NTMzI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TIuNzUwNSA2My4xOTQ5IDkyLjc1MDUgMzguMzcwMUg3OC41NTZaTTQ3LjgwMTMgNy42MTUzMkM2NC43ODY2IDcuNjE1MzIgNzguNTU2IDIxLjM4NDcgNzguNTU2IDM4LjM3MDFIOTIuNzUwNUM5Mi43NTA1IDEzLjU0NTMgNzIuNjI2IC02LjU3OTE5IDQ3LjgwMTMgLTYuNTc5MTlWNy42MTUzMlpNNDIuNTgwNSA3LjYxNTMySDQ3LjgwMTNWLTYuNTc5MTlINDIuNTgwNVY3LjYxNTMyWk00MC43MDQgNy42MTUzMkg0Mi41ODA1Vi02LjU3OTE5SDQwLjcwNFY3LjYxNTMyWiIgZmlsbD0iYmxhY2siIG1hc2s9InVybCgjZG9zdS1kLWN1dG91dCkiLz48cGF0aCBkPSJNNjguOTIxNSAzNi4wMTM1QzY4LjkyMTUgMzYuMDEzNSA2NS43MzY5IDQ5LjQ3MzggNTEuNDIzMSA0OS40NzM4QzM3LjEwOTMgNDkuNDczOCAzMi41Nzg3IDM3LjM1OTYgMzIuNTc4NyAzNi4wMTM1IiBzdHJva2U9ImJsYWNrIiB
 zdHJva2Utd2lkdGg9IjcuNjkxNjEiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [![Add Dosu to your team](https://img.shields.io/badge/Add%20Dosu%20to%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)

GitHub link: https://github.com/apache/superset/discussions/35864#discussioncomment-14799855

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
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>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](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 notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "jiderox (via GitHub)" <gi...@apache.org>.
GitHub user jiderox added a comment to the discussion: /superset/language_pack/zh/

前端代码sdk嵌入
<template>
  <div class="amount-appeal-page">
    <div class="h-[70vh] border rounded shadow-lg">
      <div id="my-superset-container"></div>
    </div>
  </div>
</template>
<style>
#my-superset-container iframe {
  width: 100%;
  height: 100vh;
  border: 0;
  overflow: hidden;
}
</style>
<script>
import { embedDashboard } from '@superset-ui/embedded-sdk'
import { getAction } from '@/api/manage'
import { USER_INFO, USER_AUTH } from '@/store/mutation-types'
export default {
  data() {
    return {
      tabIndex: 'product_tag',
      info: {},
      dashboardId: '',
      dashboardUrl: ''
    }
  },
  async mounted() {
    await getAction('/sys/bi/superSet/getSupersetDomain/').then(res => {
      this.dashboardUrl = res.result
    })
    this.embedDashboardTabs()
  },
  methods: {
    async embedDashboardTabs() {
      await getAction(`/sys/bi/superSet/getResourceIdByResourceTag/${this.tabIndex}`).then(res => {
        this.dashboardId = res.result
      })
      console.log(this.dashboardUrl + '', 'this.dashboardUrl', this.dashboardId, 'this')
      embedDashboard({
        id: this.dashboardId, // given by the Superset embedding UI
        supersetDomain: this.dashboardUrl,
        mountPoint: document.getElementById('my-superset-container'), // any html element that can contain an iframe
        fetchGuestToken: () => this.fetchEmbedGuestToken(), // guest_token
        dashboardUiConfig: {
          hideTitle: true,
          hideTab: false,
          hideChartControls: false,
          filters: {
            expanded: true,
            visible: true
          } // dashboard UI config: hideTitle, hideTab, hideChartControls (optional)
        },
        initialBootstrapData: {
          common: { locale: 'zh' }
        },
        debug: true
      })
    },
    async fetchEmbedGuestToken() {
      return new Promise(resolve => {
        getAction('/sys/bi/superSet/fetchEmbedGuestToken/', {
          dashboardTag: this.tabIndex
        }).then(res => {
          if (res.success) {
            let token = res.result
            console.log('token: ' + token)
            resolve(token)
          }
        })
      })
    }
  }
}
</script>


GitHub link: https://github.com/apache/superset/discussions/35864#discussioncomment-14802495

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "jiderox (via GitHub)" <gi...@apache.org>.
GitHub user jiderox added a comment to the discussion: /superset/language_pack/zh/

我在superset_config中配置了BABEL_DEFAULT_LOCALE = "zh"
才会有这个中文的请求接口,我的superset的前后端版本都是6.0;我嵌入sdk中是这样配置的
embedDashboard({
        id: this.dashboardId, // given by the Superset embedding UI
        supersetDomain: this.dashboardUrl,
        mountPoint: document.getElementById('my-superset-container'), // any html element that can contain an iframe
        fetchGuestToken: () => this.fetchEmbedGuestToken(), // guest_token
        dashboardUiConfig: {
          hideTitle: true,
          hideTab: false,
          hideChartControls: false,
          filters: {
            expanded: true,
            visible: true
          } // dashboard UI config: hideTitle, hideTab, hideChartControls (optional)
        },
        initialBootstrapData: {
          common: { locale: 'zh' }
        },
        debug: true
      })
      ,目前只有嵌入的页面中文显示有问题,我该怎么做

GitHub link: https://github.com/apache/superset/discussions/35864#discussioncomment-14799839

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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


Re: [D] /superset/language_pack/zh/ [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: /superset/language_pack/zh/

<!-- Greeting -->
Hi @jiderox! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.

<!-- Answer -->
你遇到的 302 跳转到登录页,是因为 /superset/language_pack/zh/ 这个接口默认需要认证,嵌入式场景下没有有效的登录态或 session,所以会被 Flask AppBuilder 重定向到登录页(302)[参考](https://github.com/apache/superset/discussions/35099#discussioncomment-14370512)。

Superset 6.0 之后,语言包已经不再通过 /superset/language_pack/ 接口动态加载,而是直接打包进前端的 bootstrap 数据,页面初始化时自动注入,不再需要单独请求接口[参考](https://github.com/apache/superset/discussions/34885)。如果你的嵌入式页面还在请求 /superset/language_pack/zh/,建议:

1. 检查你的 Superset 版本和前端代码,确保用的是官方标准的 6.0+ 版本,不要再通过接口动态加载语言包。
2. 如果有自定义代码或老版本逻辑,请升级或调整,改为直接用 bootstrap 里的语言包数据。
3. 如果确实需要接口方式,必须保证嵌入页面有有效的 Superset 登录态(比如通过 guest token 认证),否则所有受保护接口都会 302 跳转[参考](https://github.com/apache/superset/discussions/35099#discussioncomment-14370512)。

总之,推荐升级到标准用法,避免再请求 /superset/language_pack/zh/,这样嵌入式页面就能正常显示中文,无需额外认证处理。


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*

---

Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=8eb08746-b598-4def-b57b-5224a0d33f20) [![Learn about superset with Dosu](https://img.shields.io/badge/Learn%20about%20superset%20with%20Dosu-2f7b3f?style=flat&logo=data%3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DEzLjU0NTMgNzIuNjI2IC02LjU3OTE5IDQ3LjgwMTMgLTYuNTc5MTlWNy42MTUzMlpNNDIuNTgwNSA3LjYxNTMySDQ3LjgwMTNWLTYuNTc5MTlINDIuNTgwNVY3LjYxNTMyWk00MC43MDQgNy42MTUzMkg0Mi41ODA1Vi02LjU3OTE5SDQwLjcwNFY3LjYxNTMyWiIgZmlsbD0iYmxhY2siIG1hc2s9InVybCgjZG9zdS1kLWN1dG91dCkiLz48cGF0aCBkPSJNNjguOTIxNSAzNi4wMTM1QzY4LjkyMTUgMzYuMDEzNSA2NS43MzY5IDQ5LjQ3MzggNTEuNDIzMSA0OS40NzM4QzM3LjEwOTMgNDkuNDczOCAzMi41Nzg3IDM3LjM1OTYgMzIuNTc4NyAzNi4wMTM1IiBzdHJva2U9ImJsYWNrIiB
 zdHJva2Utd2lkdGg9IjcuNjkxNjEiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [![Add Dosu to your team](https://img.shields.io/badge/Add%20Dosu%20to%20your%20team-1f6feb?style=flat)](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)

GitHub link: https://github.com/apache/superset/discussions/35864#discussioncomment-14799636

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


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