nuxt3
nuxt3 copied to clipboard
$tm returns a list of functions
Reporting a bug?
I'm developping a website using the release candidate version of Nuxt3 (and prior to that the beta version). To this end, I of course use @intlify/nuxt3 to integrate vue-i18n within the website. Everything is working fine, thank you for the good work you put into it, except when it comes to lists in the locales json files. I have a contact form for which I need the users to enter information, and I wanted to use i18n for the translation. When calling $tm("someKeys"), I got the following function displayed :
(ctx) => {const { normalize: _normalize } = ctx;return _normalize(["neededTranslation"])}
I tried to call it, but it resulted in an error :
TypeError: Cannot destructure property 'normalize' of 'ctx' as it is undefined.
Expected behavior
We should get the resulted key, not a function.
Reproduction A reproducible example in codesandbox is accessible here : https://codesandbox.io/s/white-worker-oxsn11
Nuxt project info
- Operating System:
Darwin - Node Version:
v16.13.2 - Nuxt Version:
3.0.0-rc.1 - Package Manager:
[email protected] - Builder:
vite - User Config:
buildModules,intlify,modules,build - Runtime Modules:
- - Build Modules:
@nuxtjs/[email protected],@intlify/[email protected]
devDependencies
"devDependencies": { "@intlify/nuxt3": "^0.1.10", "@nuxtjs/tailwindcss": "^5.0.0-4", "@tailwindcss/forms": "^0.5.0", "nuxt": "^3.0.0-rc.1" },
System Info
System:
OS : macOS Monterey 12.3.1 (21E258) CPU : Apple M1 Memory : 8 Go
Binaries:
Node : v16.13.2 Yarn : v1.22.17 NPM : v8.6.0
Browsers:
Safari: Version 15.4 (17613.1.17.1.13) Chrome : Version 100.0.4896.127 (official Build) (arm64)
Screenshot

Additional infos As shown in #55, the new 0.2.0 version of @intlify/nuxt3 does not work yet, so I still use 0.1.10.
Validations
- [x] Read the Contributing Guidelines
- [x] Read the Documentation
- [x] Checked that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [x] Checked that this is a concrete bug.
- [x] The provided reproduction is a minimal reproducible example of the bug
I think you need to use the $rt function to parse the result returned by $tm as explained here: https://vue-i18n.intlify.dev/api/composition.html#tm-key