airflow icon indicating copy to clipboard operation
airflow copied to clipboard

i18n: Move translations to `ui/public` and enable dynamic loading to reduce bundle size

Open choo121600 opened this issue 6 months ago • 8 comments

Summary

  • Moved all translation (i18n) files from ui/src/i18n/locales to ui/public/i18n/locales.
  • Adopted i18next-http-backend to load translation files via HTTP dynamically.
  • Updated FastAPI static file serving logic to ensure translation files are accessible in both dev and prod environments.
    • Unified i18next loadPath to /static/i18n/locales/{{lng}}/{{ns}}.json for both environments.
  • Improved maintainability and scalability of the i18n system.

Details

  • i18next-http-backend allows translation files to be loaded on demand, reducing the initial bundle size and supporting dynamic language/namespace loading.
  • FastAPI dev mode now mounts the public i18n directory to /static/i18n, ensuring translation files are served correctly during development.
  • Production mode continues to serve translation files from the built dist directory.
  • The i18n config (config.ts) was updated to use a unified HTTP path for translation files, simplifying the frontend logic.

Breaking Changes

  • If we have custom scripts or tools that expect translation files in src, please update them to use the new location in public/i18n/locales.

closes: #51123

Opened a new PR to avoid potential issues with translation file conflicts in the previous one. Sorry for the inconvenience.


^ Add meaningful description above Read the Pull Request Guidelines for more information. In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed. In case of a new dependency, check compliance with the ASF 3rd Party License Policy. In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

choo121600 avatar Jun 14 '25 15:06 choo121600