Simple module for creating international routes in Nuxt3. Use module if you wanna routing like:
/en/page1 |
/es/pagina1 |=> /pages/page.vue
/ru/page1 |
Tested on all nuxt3 release candidate. Rerun application after each routes config change.
Add files into you project ;)
-
Add needed locales in app/config/locales.ts
-
Create routes in app/config/routes.ts
-
Use "LocaleLink" component for links creating by route name
<LocaleLink :route-name="$RouteNames.SomeRoute"
:route-params="{ param1: 'foo' }">Link to same locale</LocaleLink>
<LocaleLink :locale="ru"
:route-name="$RouteNames.SomeRoute"
:route-params="{ param1: 'foo' }">Link to RU locale</LocaleLink>
or by url string
<LocaleLink :route-string="/en/">Main page on EN</LocaleLink>
- Add "DOMAIN" constant in nuxt public runtime config
....
runtimeConfig: {
public: {
DOMAIN: "https://my.site", //used in "plugins/routes/path" helper function with absolute parameter
}
}
...