adbrosaci / vue-lang-router

Vue language routing with (optional) localized URLs.
MIT License
66 stars 8 forks source link

Options of the VueI18n constructor. #7

Closed pronikell closed 3 years ago

pronikell commented 3 years ago

Hello @radek-altof. Thank you for your work. I have a problem with custom options for vue-i18n. (ex. DateTime, Pluralization etc. ) They cannot be transferred to a plugin vue-i18n.

I use a workaround:

--- a/src/plugin/index.js
+++ b/src/plugin/index.js
@@ -105,7 +105,9 @@ LangRouter.install = function (Vue, options) {
        i18n = new VueI18n({
                locale: defaultLanguage,
                fallbackLocale: defaultLanguage,
-               messages,
+               messages: messages,
+               dateTimeFormats: options.i18nSettings.dateTimeFormats,
+               pluralizationRules: options.i18nSettings.pluralizationRules
        });

and router/index.js:

Vue.use(LangRouter, {
  defaultLanguage: 'ru',
  translations,
  localizedURLs,
  i18nSettings
})

i18nSettings - dateTimeFormats: {...}, pluralizationRules: {..}

PS I see that vue3+ssr support is appearing, it' very cool. :+1:

radek-altof commented 3 years ago

Hi @pronikell, thanks for pointing that out. You're right, this should be added as an option. Will take a look at it.

radek-altof commented 3 years ago

Solved in v1.3.0 for Vue 2 and v2.1.1 for Vue 3.