nativescript-localize
nativescript-localize copied to clipboard
The instruction for Vue is out-of-dated
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 <Label :text="'test'|L"/> works like charms while <Label :text="'I am %s'|L('user name')"></Label> will yield errors.
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.
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.filter
and directly declare the function for every Vue instance using Vue.prototype.L = localize