Hi @EddyVerbruggen,
I use currently this plugin on my prod App, since we can not edit the Resources file and the translate wont be affected by the update. I've thought about how we can update the text or the translate on the app. I have done a little test, it work but I dont know how much it is a good solution !!
The idea is :
On the nativescript-app-sync side :
add a new options syncWithNsLocalize if it is set, create new boolean on the application settings __SYNC_NS_LOCALIZE__
On the nativescript-localize side :
1- if __SYNC_NS_LOCALIZE__ is set, we will import the json file __app__language__.json into localize.android.ts and localize.ios.ts
2- Override the string if the value that come from the json file dont match with the value from the resources file
I know the parser it is bizarre but I haven't thought about it yet if there is a better way to achieve this
// here it is the localize.ios.ts
const data = require('__app__language__.json');
let str = parser.parse(data, key, args);
if(str !== null && str !== vsprintf(convertAtSignToStringSign(localizedString), args)) {
console.log("VALUE ARE NOT SAME !")
return str;
}
return vsprintf(convertAtSignToStringSign(localizedString), args);
const parser = {
parse: (data: any, key: string, args?: any): string => {
try {
let splits = key.split(".");
let value = null;
for(let i = 0; i < splits.length; i++) {
switch(i) {
case 0:
value = parser.value(data[splits[0]]);
break;
case 1:
value = parser.value(data[splits[0]][splits[1]]);
break;
case 2:
value = parser.value(data[splits[0]][splits[1]][splits[2]]);
break;
case 3:
value = parser.value(data[splits[0]][splits[1]][splits[2]][splits[3]]);
break;
case 4:
value = parser.value(data[splits[0]][splits[1]][splits[2]][splits[3]][splits[4]]);
break;
case 5:
value = parser.value(data[splits[0]][splits[1]][splits[2]][splits[3]][splits[4]][splits[5]]);
break;
}
}
return vsprintf(value, args);
} catch(e) {
console.log(e)
return null;
}
},
value: (data) => {
return data !== "undefined" ? data : null;
}
}
Hi @EddyVerbruggen,
I use currently this plugin on my prod App, since we can not edit the
Resourcesfile and the translate wont be affected by the update. I've thought about how we can update thetextor thetranslateon the app. I have done a little test, it work but I dont know how much it is a good solution !!The idea is :
On the
nativescript-app-syncside :add a new options
syncWithNsLocalizeif it is set, create new boolean on the application settings__SYNC_NS_LOCALIZE__On the
nativescript-localizeside :1- if
__SYNC_NS_LOCALIZE__is set, we will import the json file__app__language__.jsonintolocalize.android.tsandlocalize.ios.ts2- Override the string if the value that come from the json file dont match with the value from the resources file
I know the parser it is bizarre but I haven't thought about it yet if there is a better way to achieve this