nuxt-community / dayjs-module

Day.js module for your Nuxt 2 project.
https://www.npmjs.com/package/@nuxtjs/dayjs
MIT License
261 stars 16 forks source link

Locales and defaultLocale #303

Open gldkru opened 3 years ago

gldkru commented 3 years ago

Hey! Thanks for your module

I have set default locale and locales, but who should switch them and where?

    ...
    locales: ['ru', 'en'],
    defaultLocale: 'en',

OK, i18n module changed language, what's next?

shakhzodkudratov commented 3 years ago

hey dude, here is it. add this to nuxt.config.js -> plugins array:

export default function ({ i18n, $dayjs }) {
  i18n.beforeLanguageSwitch = (oldLocale, newLocale) => {
    $dayjs.locale(newLocale)
  }
}