In Google Play you can translate your app using a XML file, Can I have the same “code” and a file with the diferents strings to translate?
Or how can I have the same app in some languajes.
Thanks in advance
In Google Play you can translate your app using a XML file, Can I have the same “code” and a file with the diferents strings to translate?
Or how can I have the same app in some languajes.
Thanks in advance
Hi,
one way of doing it would be this:
Make an object with the different translations of each block of text.
{ "intro": { "en": "welcome to my great app", "es": "bienvenido a mi app" }, "contact": { "en": "write your email here", "es": "ingresa su correo aqui" } }
Stick it in a service so you can get to it from all controllers.
configure a localstorage object with the chosen language and then filter the object so for each value (intro,contact,…) you have the correct translation connected.
Now you can call this object directly in your controller with the right translation.
You can do it with JavaScript only using:
ng-translate (Ionic 1) - https://github.com/angular-translate/angular-translate
Tutorial: https://blog.nraboy.com/2014/08/internationalization-localization-ionicframework-angular-translate/
ng2-translate (Ionic 2) - https://github.com/ocombe/ng2-translate
Tutorial: http://www.gajotres.net/ionic-2-internationalize-and-localize-your-app-with-angular-2/
I used JSON files, named translation_<country_code>.json .
country_codes come from localisation.getPreferredLanguage()
then i store the translation object, and i’m able to access it anywhere in my app.