Previous configuration

nuxt.config.ts

{
  i18n: {
    vueI18n: "./i18n.config.ts",
    locales: ["en", "zh"], // used in URL path prefix
    defaultLocale: "en", // default locale of your project for Nuxt pages and routings
    strategy: "prefix_except_default",
  },
}
  • strategy: "prefix_except_default", means create prefix routes for all routes except the default language.
  • detectBrowserLanguage: false, whether to automatically jump to the corresponding route according to the browser language, enabled by default.

Helpful Functions

  • useLocalePath, Generates a corresponding route path string in the current language for an unprefixed path.
  • useLocaleRoute, Generates the corresponding route object of the current language for the unprefixed path.