EddyVerbruggen / nativescript-localize

Internationalization plugin for NativeScript using native capabilities of each platform
MIT License
79 stars 31 forks source link

The instruction for Vue is out-of-dated #59

Open shilik opened 5 years ago

shilik commented 5 years ago

Hi, ifabreges Thanks for the great plugin. It took me a while figuring out how to make it work on my nativescript-vue project. As nativescript-vue has been updated to 2.0. The following settings work for me.

in main.js file const application = require("application"); const localize = require("nativescript-localize"); application.setResources({ L: localize }); Vue.filter("L", localize);

in abc.vue file

lfabreges commented 5 years ago

I tested it and adding the L pipe to the application resources isn't required. It seems that nativescript is not taking into account the modified strings file at build time, it only takes it into account during the next build. I don't know how to fix that for now.

elie-g commented 5 years ago

With Vue.filter, it just doesn't work for me...

Whatever I try it always crash with a message saying _vm.L is not a function.

The only way I found to make it work is to not use Vue.filterand directly declare the function for every Vue instance using Vue.prototype.L = localize