jaredmcateer / ngVue3

Use Vue 3 components in your Angular 1.x app
https://jaredmcateer.github.io/ngVue3/
MIT License
20 stars 2 forks source link

Connecting plugins to Vue (i18n) #33

Closed XShep closed 1 year ago

XShep commented 1 year ago

Hello, i would like to connect the i18n translations to the ngVue. Tried a lot of examples, searching inside the main files. I saw that you did plugins functionality, but can you please explain how to use it, and connect for example i18n?

jaredmcateer commented 1 year ago

Hi, It looks like it depends whether you're using composition api or options api in your code. Make sure you're using v9 of i18n.

If you're using Options api, instead of app.use(i18n), you need to call $ngVueProvider.use(i18n) as described in the Plugin/Use/Directives docs

If you're using Composition API it looks like i18n provides a composable that you can use to use in your setup functions (or script setup), so there should be no need to config ngVue at all for it.

XShep commented 1 year ago

Much thanks, i didn't found your documentation before. I'll close issue after successful tests.

XShep commented 1 year ago

Having problem with syntax, but in your example it is the same. Saying me, that the : is unexpected in config of angular module

const ngVue = ngVue3.useNgVue();
const ngVuePlugins = ngVue3.useNgVuePlugins();

angular.module("vue.components", [ngVue, ngVuePlugins])
    .config(($ngVueProvider: NgVueProvider) => {
        $ngVueProvider.use(i18n);
    });

Maybe that happens because i'm importing without import statement? Btw ngVue works like that

jaredmcateer commented 1 year ago

Are you using TypeScript? If not remove : NgVueProvider. I should probably clarify that in the docs.

XShep commented 1 year ago

Yeah, thanks a lot for help! Now it works