You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.tsconstdata=require('__app__language__.json');letstr=parser.parse(data,key,args);if(str!==null&&str!==vsprintf(convertAtSignToStringSign(localizedString),args)){console.log("VALUE ARE NOT SAME !")returnstr;}returnvsprintf(convertAtSignToStringSign(localizedString),args);constparser={parse: (data: any,key: string,args?: any): string=>{try{letsplits=key.split(".");letvalue=null;for(leti=0;i<splits.length;i++){switch(i){case0:
value=parser.value(data[splits[0]]);break;case1:
value=parser.value(data[splits[0]][splits[1]]);break;case2:
value=parser.value(data[splits[0]][splits[1]][splits[2]]);break;case3:
value=parser.value(data[splits[0]][splits[1]][splits[2]][splits[3]]);break;case4:
value=parser.value(data[splits[0]][splits[1]][splits[2]][splits[3]][splits[4]]);break;case5:
value=parser.value(data[splits[0]][splits[1]][splits[2]][splits[3]][splits[4]][splits[5]]);break;}}returnvsprintf(value,args);}catch(e){console.log(e)returnnull;}},value: (data)=>{returndata!=="undefined" ? data : null;}}
The text was updated successfully, but these errors were encountered:
Interesting idea.
So we could technically also add new localisation strings on the fly.
Instead of using the switch case, we could do something like this,
That way it can handle any length of splits :)
Not sure of the performance implications though.
It would be worth stress testing this on a large application.
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 thetext
or thetranslate
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
intolocalize.android.ts
andlocalize.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
The text was updated successfully, but these errors were encountered: