N
Nuxt5mo ago
ægteemil

Strongly typed i18n

Hey. I'm using the i18n module for nuxt, and I'm wondering if there's a way to achieve type-safety when using translation keys in template? So instead of a magic string, being able to reference something type-safe indicating that they key exists
<p>{{ $t('hello.world') }}</p>
<p>{{ $t(hello.world) }}</p> // this would be nice
<p>{{ $t('hello.world') }}</p>
<p>{{ $t(hello.world) }}</p> // this would be nice
1 Reply
sexyGaming - Kiroma
You could always provide that by indirection (having an object containing your root translation as plain js/ts object which you then include in your components (or auti-import) and add into the i18n module as your value object). But maybe this https://github.com/nuxt-modules/i18n/issues/1753 woudl also already alleviate all your problems when it someday gets implemented?
GitHub
$t() autocomplete support · Issue #1753 · nuxt-modules/i18n
Describe the feature Hello, It would be really nice to have auto completion feature while using t('welcome') in template, especially when you want to reuse keys in different sections. Addit...
Want results from more Discord servers?
Add your server