Reputation: 3328
Does anyone have experience to build phonegap app that support multiple languages (english, french, german etc...) ? I'm looking a way to change ui of my app most efficent with javascript. It would be helpful when you can show me any existing javascript libs that can help me to do this.
Thanks
Edited:
i edited the question so that it's more understandable.
Upvotes: 2
Views: 18222
Reputation: 1541
Just saw this and figured it is a little late to comment but I would put it up anyway for anyone else's reference. We recently did an app that has english and bahasa indonesian language support. We used Knockout.js and a resource file to accomplish this. All it has is a resources file that looks something like this.
"en":{
"exploreMapsButton":"Explore Maps"
},
"bh":{
"exploreMapsButton":"Lihat Peta"
}
Then we would bind an html element to Knockout's ViewModel and if the app was being displayed in english, we would update the ViewModel with all the values under en, if it was in indonesian then we would update the ViewModel with values from bh. This has worked really well and is very easy to maintain as their is no dom manipulation, just update your ViewModel with all the right resources and Knockout handles the rest.
Upvotes: 1
Reputation: 1447
Assuming you are talking about spoken languages here, you just need to replace all your hard coded strings in your HTML such that they they are inserted during a templating phase and looked up in a table of string values, which table to string values that is used can be determined by what language the application is operating in. There was a good article on this topic on 24ways a while back, check it out here. The article is for JavaScript so it certainly applies for a PhoneGap application.
Upvotes: 2