fix(i18n): resolve raw studio.* keys when host app uses @nuxtjs/i18n - #501
fix(i18n): resolve raw studio.* keys when host app uses @nuxtjs/i18n#501Codermar wants to merge 6 commits into
Conversation
|
@Codermar is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
Thanks for your pull request, @Codermar ! |
useUI.setLocale relied on getCurrentInstance(), which is null when useStudio initializes inside a shared composable effectScope. Capture Studio i18n.global in configureApp and eager-load en messages so locale chunks load before the first paint. Fixes nuxt-content#104
Assert useUI.setLocale resolves Studio labels when called from an effectScope, including lazy-loaded locale chunks.
Keep playground/minimal as the baseline Content + Studio setup and add a sibling fixture that mirrors nuxt-content#104.
Split content into locale folders with per-locale collections so Studio smoke tests show a multi-language tree for nuxt-content#104. Query the correct content path per locale (/fr for French).
Runs dev:prepare + prepack so pnpm can install nuxt-studio from GitHub (tarball has no dist/; needed for monorepo deploy pins).
5dfea6c to
ec69cf9
Compare
Done — split into two PRs as suggested. This PR now contains only the i18n locale loading fix (#104). The UIcon size prop fix is in a separate PR: fix(ui): use class sizing on UIcon instead of invalid size prop |
Regenerate pnpm-lock.yaml after merging main's @nuxt/ui and docus upgrades with the minimal-i18n playground workspace.
|
@hendrikheil i noticed this PR is still open after a while as well as others in this repo. This is a package that interests me and I wonder if I can help some more review the prs or some other tasks that can facilitate the package to move forward. Also, I'd be interested to know if there's roadmap for it or if the continued maintenance is in the plans. |
Fixes #104
Summary
When a host Nuxt app uses
@nuxtjs/i18n, Studio could show raw translation keys (e.g.studio.nav.content,studio.nav.media) instead of localized labels. This PR fixes locale loading so Studio UI strings resolve correctly in that setup.Problem
Studio initializes locale from
useStudioinside a shared composable scope — not from a Vue component.setLocale()previously relied ongetCurrentInstance()to reachi18n.global, so it often ran with no component context. Locale JSON chunks were never loaded, and vue-i18n fell back to displaying keys.This shows up in real apps that combine Nuxt Content, Studio, and
@nuxtjs/i18n(e.g. multilingual CMS sites).Solution
i18n.globalat app setup time (main.ts→configureApp)studioI18n.ts) inuseUI.setLocale()enon startup; lazy-load other locales only when neededChanges
studioI18n.ts,main.ts,useUI.tssetLocaleinsideeffectScope(eager + lazy locales)playground/minimal-i18n— host app with@nuxtjs/i18nfor manual validationTest plan
Automated
pnpm verify(unit tests includestudioI18n.test.ts)Manual
pnpm dev:app(Studio app on:5151)pnpm dev:minimal-i18n(playground on:3000)http://localhost:3000and toggle Studio (⌘.)studio.nav.*keys)/fr) and reopen Studio — labels should show Contenu / MédiaNotes
playground/minimalis unchanged;minimal-i18nis an optional sibling playground, not a change to the default dev setup.@nuxtjs/i18nis configured — only Studio's internal locale loading.