Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression: Closed setLocale, setLocaleCookie functions undefined in useI18n composable when using per-component translations #2335

Closed
kazupon opened this issue Aug 21, 2023 · 3 comments · Fixed by #2340
Labels
API ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf regression v8

Comments

@kazupon
Copy link
Collaborator

kazupon commented Aug 21, 2023

I have the same issue, even if I use the edge version.

I forked the @borghol stackbliz sample to reproduce the issue with latest Nuxt and i18n versions.

With latest versions:
- @nuxtjs/i18n: 8.0.0-rc.3
-  nuxt: 3.6.2
https://stackblitz.com/edit/nuxt-starter-ivgcei?file=package.json,pages%2Fwith_translation.vue

With edge versions:
- @nuxtjs/i18n: @nuxtjs/i18n-edge
-  nuxt: nuxt3@latest
https://stackblitz.com/edit/nuxt-starter-bboakf?file=package.json,pages%2Fwith_translation.vue

With these version it's working well:
- @nuxtjs/i18n: 8.0.0-beta.10
- nuxt: 3.6.5
https://stackblitz.com/edit/nuxt-starter-jbjcdt?file=package.json

But after the next version (8.0.0-beta.11) the issue came back.

Thanks

Originally posted by @guitoun3 in #1857 (comment)

@guitoun3
Copy link

Hi @kazupon,

Is the fix available in the edge channel?

Because this stackblitz (using edge channel) is still not working: https://stackblitz.com/edit/nuxt-starter-bboakf?file=package.json,pages%2Fwith_translation.vue

Thank you

Copy link
Collaborator Author

kazupon commented Aug 25, 2023

Hi!
I think that stackblitz isn't good reproduction code, but I could work setLocale, setLoaleCookie and per-component translations at there

@guitoun3
Copy link

guitoun3 commented Aug 25, 2023

On my side the route /without_translation is working well but not the /with_translation.
When I used @nuxtjs/i18n: 8.0.0-beta.10 both routes were working well.

In the with_translation component I cannot make the setLocale function to work.

<template>
  <div>
    {{ t('hello') }}
  </div>
</template>
<script setup>
const { t, setLocale, setLocaleCookie } = useI18n({ useScope: 'local' });
setLocale('es');
</script>
<i18n lang="json">
{
  "en": { "hello": "Hello Local" },
  "fr": { "hello": "Bonjour Local" },
  "es": { "hello": "Hola Local" }
}
</i18n>

When I call it I get a 500 error with this message: setLocale is not a function
And in the console I get this error:

[nitro] [unhandledRejection] TypeError: $setup.t is not a function                                                                                             08:16:36
    at _sfc_ssrRender (file:///home/projects/nuxt-starter-bboakf/pages/with_translation.vue:27:49)
    at renderComponentSubTree (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:683:9)
    at renderComponentVNode (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)
    at renderVNode (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:743:14)
    at renderComponentSubTree (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:698:7)
    at renderComponentVNode (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)
    at renderVNode (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:743:14)
    at renderVNode (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:747:9)
    at renderComponentSubTree (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:698:7)
    at renderComponentVNode (file:///home/projects/nuxt-starter-bboakf/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf regression v8
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants