You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
i18n - Load translation files from a backend #51123
Right now all of the translation json files are in the UI js bundle at runtime. We should move them to the server and only load the translation currently being used.
The initial PR for i18n left TODO comments for the places we need to change in the UI to handle this.
I'm planning to move the i18n translation files from the UI bundle (airflow-core/src/airflow/ui/src/i18n/locales/{lang}/{ns}.json) to the backend.
I’d like to get input on the best place to put the directory.
Or would it be better to manage them as a core Airflow resource like airflow-core/src/airflow/i18n/locales/? @bbovenzi Do you already have any preferred location in mind?
If I also may suggest - should we use yaml maybe instead of json? It's simple enough to fix all the scripting we have, and I Find json in this context overly verbose and prone to errors (especially when you copy lines and there is a dangling comma).
Thanks for the suggestion @potiuk !
I totally agree that yaml is more human-friendly and reduces the risk of syntax errors compared to json, especially when translators manually edit the files.
Currently, the reason we use json is that i18next by default expects translation files in json format on the client side, and loading yaml directly in the browser would require bundling a yaml parser, which would increase the frontend bundle size something we want to avoid for performance reasons.
To get the best of both worlds, I’m considering the following approach:
Store and maintain translation files in yaml format on the backend (making it easier for contributors to edit and review)
Serve the translations through an API endpoint that loads yaml files, parses them on the server, and returns json responses
Let the frontend continue to load translations as JSON via i18next’s standard HTTP backend without extra yaml parsing in the client
This way, we keep the translation source files developer and contributor-friendly with yaml, while preserving frontend performance and compatibility with existing i18next tooling.
Would love to hear your thoughts or concerns on this approach!
I think you can simply move the translation files to airflow/airflow-core/src/airflow/ui/public. When built, that will not be part of the bundle, and the output dist folder is already served from the backend as a static folder.
For example the pin_100.png image is already accessible at /static/pin_32.png (dev mode needs to be handled slightly differently, but that already works for other public assets, should be similar for translations)
Thanks @pierrejeambrun ! That's a great point using airflow/airflow-core/src/airflow/ui/public definitely keeps things simple and fits nicely with how other frontend assets are handled.
If we weren’t aiming to serve translation files from the backend as the issue title suggests I would have gone with that approach too.
I also think the discussion around improving contributor experience (DX) with YAML, as @potiuk suggested, is very valuable. To achieve both goals, how about we take a two-step approach?
First (For 3.1.0): We implement your simple solution now to fix the urgent bundle size problem and meet the milestone.
Then (As a follow-up): I'll create a new issue to tackle the DX improvements, like YAML processing, for a future release.
This allows us to meet the 3.1.0 milestone while still planning for long-term enhancements.
What does everyone think of this plan?
Sure. Switching to yaml is just a small improvement, it is not "necessary". And if it makes things easier/less dependencies with serving files directly it can stay like that even.
Activity
choo121600 commentedon May 28, 2025
I'd like to help on this issue. Could you assign it to me? 👀
bbovenzi commentedon May 28, 2025
@choo121600 go for it!
choo121600 commentedon Jun 5, 2025
I'm planning to move the i18n translation files from the UI bundle (airflow-core/src/airflow/ui/src/i18n/locales/{lang}/{ns}.json) to the backend.
I’d like to get input on the best place to put the directory.
For example:
api_fastapi/core_api/i18n/locales/{lang}/{ns}.jsonapi_fastapi/common/static/i18n/locales/{lang}/{ns}.jsonOr would it be better to manage them as a core Airflow resource like
airflow-core/src/airflow/i18n/locales/?@bbovenzi Do you already have any preferred location in mind?
potiuk commentedon Jun 5, 2025
Good idea.
potiuk commentedon Jun 5, 2025
If I also may suggest - should we use
yamlmaybe instead of json? It's simple enough to fix all the scripting we have, and I Find json in this context overly verbose and prone to errors (especially when you copy lines and there is a dangling comma).bbovenzi commentedon Jun 5, 2025
They are just static files so I think option 1 makes sense to me. What do you think @pierrejeambrun ?
choo121600 commentedon Jun 6, 2025
Thanks for the suggestion @potiuk !
I totally agree that
yamlis more human-friendly and reduces the risk of syntax errors compared tojson, especially when translators manually edit the files.Currently, the reason we use
jsonis that i18next by default expects translation files in json format on the client side, and loading yaml directly in the browser would require bundling a yaml parser, which would increase the frontend bundle size something we want to avoid for performance reasons.To get the best of both worlds, I’m considering the following approach:
This way, we keep the translation source files developer and contributor-friendly with yaml, while preserving frontend performance and compatibility with existing i18next tooling.
Would love to hear your thoughts or concerns on this approach!
potiuk commentedon Jun 6, 2025
Yep. 100%. I'd do it exactly the same I figured that Json was because of the client side
pierrejeambrun commentedon Jun 10, 2025
I think you can simply move the translation files to
airflow/airflow-core/src/airflow/ui/public. When built, that will not be part of the bundle, and the outputdistfolder is already served from the backend as a static folder.For example the
pin_100.pngimage is already accessible at/static/pin_32.png(dev mode needs to be handled slightly differently, but that already works for other public assets, should be similar for translations)choo121600 commentedon Jun 12, 2025
Thanks @pierrejeambrun ! That's a great point using
airflow/airflow-core/src/airflow/ui/publicdefinitely keeps things simple and fits nicely with how other frontend assets are handled.If we weren’t aiming to serve translation files from the backend as the issue title suggests I would have gone with that approach too.
I also think the discussion around improving contributor experience (DX) with YAML, as @potiuk suggested, is very valuable. To achieve both goals, how about we take a two-step approach?
This allows us to meet the 3.1.0 milestone while still planning for long-term enhancements.
What does everyone think of this plan?
potiuk commentedon Jun 12, 2025
Sure. Switching to yaml is just a small improvement, it is not "necessary". And if it makes things easier/less dependencies with serving files directly it can stay like that even.
pierrejeambrun commentedon Jun 12, 2025
Sounds good to me.