panter / vue-i18next

Internationalization for vue using the i18next i18n ecosystem.
https://panter.github.io/vue-i18next/
176 stars 47 forks source link

Install the plugin without the new Vue #61

Open gpessa opened 5 years ago

gpessa commented 5 years ago

I have a Vue app. And I have build a Vue plugin which contains all my UI component. I would like that my UI plugin would also contain the i18n functionality. Installing it it should add all my filters/component/directives and the i18n. This is the code I would like to write:

let VueUi = Vue => {

  Vue.use(VueI18Next);

  i18next.init({
    lng: 'de',
    resources: {
      ...
    }
  });

  Object.values(Components).forEach(Component => {
    Vue.use(Component);
  });

  Object.values(Directives).forEach(Directive => {
    Vue.use(Directive);
  });

  Object.values(Filters).forEach(Filter => {
    Vue.use(Filter);
  });
};

The problem is that I get an error. I suppose because I miss this part:

new Vue({
  ...
  i18n: i18n,
});

Do I have a way to not write this code?

alexmiddeleer commented 4 years ago

This would be helpful for allowing translations in storybook as well.