Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt-i18n integration #77

Open
mrleblanc101 opened this issue Apr 8, 2021 · 1 comment
Open

Nuxt-i18n integration #77

mrleblanc101 opened this issue Apr 8, 2021 · 1 comment

Comments

@mrleblanc101
Copy link

mrleblanc101 commented Apr 8, 2021

Hello,
I think this plugin should work seamlessly with nuxt-i18n, another official Nuxt module.
Currently, for every project, I need to setup a plugin so nuxt-moment and nuxt-i18n work properly togerther.

$moment.locale(app.i18n.locale);
app.i18n.beforeLanguageSwitch = async (oldLocale, newLocale) => {
    $moment.locale(newLocale);
};
@mrleblanc101 mrleblanc101 changed the title Integration with Nuxt-i18n Nuxt-i18n integration Apr 8, 2021
@devilmark84
Copy link

Cool, in general I prefer to have a single i18n.ts plugin to handle every component language settings:

export default ({ app }: any) => {
  const switchLanguage = (_old: string | undefined, localeCode: string) => {
    app.vuetify.framework.lang.current = localeCode;
    app.$moment.locale(localeCode);
  };

  app.i18n.onBeforeLanguageSwitch = switchLanguage;
  switchLanguage(undefined, app.i18n.locale);
};```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants