Skip to content

Conversation

@mistercrunch
Copy link
Member

@mistercrunch mistercrunch commented Jul 10, 2025

Since forever we've been doing this dubious thing of passing the language pack through the dom. The server fetches the json file, and serializes it into a dom node as part of the "bootstrap data". Frontend picks it up deserializes it and hooks things up.

In this PR:

  • creating a super simple flask endpoint to serve the json files safely (made sure to only serve the right files...)
  • changing the "preamble" to run an async call to fetch the language pack before doing anything

Since forever we've been doing this dubious thing of passing the language pack through the dom. The server fetches the json file, and serializes it into a dom node as part of the "bootstrap data". Frontend picks it up deserializes it and hooks things up.

In this PR:
- creating a super simple flask endpoint to serve the json files
- changing the "preamble" to run an async call to fetch the language pack before doing anything
@github-actions github-actions bot added the api Related to the REST API label Jul 10, 2025
@dosubot dosubot bot added change:backend Requires changing the backend i18n Namespace | Anything related to localization labels Jul 10, 2025
Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Redundant Initial Configuration ▹ view ✅ Fix detected
Files scanned
File Path Reviewed
superset-frontend/src/preamble.ts
superset/views/base.py
superset/views/core.py
superset/config.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

import { User } from './types/bootstrapTypes';
import getBootstrapData, { applicationRoot } from './utils/getBootstrapData';

configure();

This comment was marked as resolved.

@github-actions github-actions bot added preset-io and removed i18n Namespace | Anything related to localization labels Jul 10, 2025
Copy link
Member

@msyavuz msyavuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

import { User } from './types/bootstrapTypes';
import getBootstrapData, { applicationRoot } from './utils/getBootstrapData';

configure();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? Is there a loading happening between this and the language pack loading?

Copy link
Member Author

@mistercrunch mistercrunch Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unclear what exactly it does, but it prepares a bunch of things around the various "registries" and such. It logs a bunch of things to the console if called too late. Might be worth digging a bit deeper. I'll double check there's no important perf costs in calling it twice.

@mistercrunch mistercrunch merged commit c42be77 into master Jul 14, 2025
56 checks passed
@mistercrunch mistercrunch deleted the async_language_pack branch July 14, 2025 17:59

@event_logger.log_this
@has_access
@expose("/language_pack/<lang>/")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mistercrunch It would be nice to put this endpoint under /api/v1 to be an official endpoint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I thought through this wondering if this is a private or public endpoint, and thought ideally should be public, but given the partitioning of libraries in the frontend, and the fact that our i18n framework is monolithic currently (no segmentation or context based on the provenance of the strings), it felt like it would require significantly more work to do this properly.

Not sure whether the extension framework SIP mentions i18n, but it may be a bit of a blindspot.

Without going to deep into it, it seems that if we want for extensions to be localized/localizable, we'd need some way to segment the language pack based on package provenance (backend/frontend, and break down per library on the frontend side). The whole i18n stack might need to offer different ways to fetch and apply translations.

Happy to help think through this, but it's a fairly significant amount of work.

Note that one minor and valuable thing I considered while doing the work here was to find a way to add metadata to translation to identify what is frontend/backend, and make sure the endpoint only returns the strings intended for the frontend ... The gettext-based/flask-babel framework we use does offer ways to do such things, but I encountered some limitations, and decided to punt on these.

This PR here addresses something pretty important - removing the language pack from bootstrap data - but there's much more to do in this area.

ianngech pushed a commit to Pesapal-Ltd/superset that referenced this pull request Jul 17, 2025
dankor pushed a commit to dankor/superset that referenced this pull request Aug 18, 2025
@github-actions github-actions bot added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 6.0.0 First shipped in 6.0.0 labels Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels change:backend Requires changing the backend preset-io size/L 🚢 6.0.0 First shipped in 6.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants