Internationalization
For internationaliztion supastarter integrates nuxt/i18n.
Why nuxt/i18n:
nuxt/i18n is a lightweight internationalization library based on
vue-i18n especially designed to leverage Nuxt
3 features (auto-imports, file-based route generation, etc.). It also supports
automatic language detection and url based language routing.
Usage
In Vue components, you can use the auto-imported composable useTranslations(). This composable exposes the useI18n() composable from nuxt/i18n and adds types for the translation keys.
Localized Links
nuxt/i18n also auto-imports useLocalePath(), a useful composable to generate localized links.
If you want to use a link, the auto-imported component <NuxtLinkLocale> is built on top of <NuxtLink>
but changes the default behavior by internally using localePath() to make it easier to link to localized routes.
is equivalent to
Translations
Translations are stored in the packages/i18n/translations folder. The default locale is en and the translations are stored in en.json.
Add a new locale
To add a new locale you need to create a new file in the packages/i18n/translations folder with the locale name as the file name. For example fr.json for French.
Then register this locale in the global config file: