Comfy-Org / Comfy-Org/ComfyUI_frontend
Duplicated i18n setup between src/ and apps/desktop-ui
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 699
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 490
Description
## Problem
`src/i18n.ts` (216 lines) and `apps/desktop-ui/src/i18n.ts` (190 lines) contain near-identical code:
- Same `buildLocale()` function
- Same `loadLocale()` async function with loading/dedup logic
- Same 4 parallel loader maps (localeLoaders, nodeDefsLoaders, commandsLoaders, settingsLoaders)
- Same `st()` convenience function
- Same `createI18n()` configuration
- Same `loadedLocales` / `loadingLocales` tracking
The only differences are:
- Import paths: `./locales/` vs `@frontend-locales/`
- desktop-ui omits `mergeCustomNodesI18n()` and the `d` (date formatter) export
- desktop-ui is missing the `fa` (Farsi) locale
### Impact
- Bug fixes or locale additions must be applied in both files
- Locale list can drift out of sync (already has: desktop-ui missing `fa`)
- ~400 total lines of duplicated boilerplate
### Suggested fix
Extract a shared i18n factory to `packages/shared-frontend-utils` that:
1. Accepts a locale resolver function (to handle different import paths)
2. Returns `i18n`, `t`, `te`, `st`, `loadLocale`
3. Both apps consume the factory with their own resolver
### Files involved
- `src/i18n.ts`
- `apps/desktop-ui/src/i18n.ts`
Parent: #11022
┆Issue is synchronized with this [Notion page](https://www.notion.so/Issue-11100-Duplicated-i18n-setup-between-src-and-apps-desktop-ui-33e6d73d365081548a47caeee51bfd20) by [Unito](https://www.unito.io)
Contributor guide
Assessment
This issue has not been assessed yet.