I have a completed Titanium Android application (that the developer was not me).
I want to localize it but both the strings and the UI are hard coded in the source code.
The application built in javascript.
The UI is also important because we also want a right-to-left version of the app.
Need to mention that I'm pretty new to the Titanium environment.
What is the best approach to this task?
You would need to take the source code and find all the hard coded strings and move them to the il8n/ folder's string.xml file. You would need to create one of these files in the appropriate language directory with the string that corresponds to the particular hard coded value you want to represent.
For example:
var mystring = L('hi_text');
In Titanium, this code would go to the language folder (of the device's setting, i.e. English or en folder) and look for an entry like this:
il8n/en folder:
<string name="hi_text">Hello</string>
If the device was in Spanish language mode, that same code would then look to the il8n/es folder:
<string name="hi_text">Hola<string>
That would allow you to switch the language, but changing the UI would likely be a significant change to the source code. In the app.js file, you may attempt to detect the language of the device and branch to completely different logic for the screens. You could also do this in the particular screen javascript files as well, where you call one creation function for each different language. You will likely be changing the architecture of the application if it didn't already have that requirement built-in.
Here is the official document :
https://developer.appcelerator.com/question/125732/localization-not-working
Related
I'm working on an Android app. I need to make it available in many languages.
Can we use Google Translate Plugin or translate API to get this work ?
Please check this link : https://www.w3schools.com/howto/tryit.asp?filename=tryhow_google_translate
You can see there's a drop down to get all the language list.
Can I use something like this in my Android app ?
If I can't use a this method, what's the best way to enable multi-language feature in an Android app ?
Every android app has a resource value "strings" (a list of values for string variables) to provide different languages.
<resources>
<string name="home_act_bottom_bar_home_item">Shop</string>
<string name="home_act_bottom_bar_cont_item">Contacts</string>
<string name="home_act_bottom_bar_cart_item">Cart</string>
</resources>
The application must have a new string res file for each language. When the application is launched, the OS detects current system language which was chosen by user in android settings and then try to find this language in res files. If the file we need exists (for example Russian) it will be used, if not - the system will start application with default strings res file(often English). You certainly may use different web-services to translate you "Strings" after application was launched, but it will need time, will make user experience worth (user will have to wait for translation and UI update), will make your code very complex. I suggest you to translate your App beforehand, and put translations to according string res files, it will make your app fast and code not so complex.
You can read official docs here: https://developer.android.com/training/basics/supporting-devices/languages
When you want to add locale-specific resources in Android, you have to add the lowercase ISO-3166-1 code of the language to the resource folder's name. So far so good.
Now I want to add Catalan and Basque strings to my application. According to the ISO list, I would have to add values-ca and values-eu. But will that work, actually?
Edit: With a custom language chooser in your app, you can provide support for languages even when they're not in the device's settings menu. I've made the library that I use for this available on GitHub:
https://github.com/delight-im/Android-Languages
I don't know if Android supports all ISO codes and if these "minor" languages will be displayed at all. If Android is not available in these languages, perhaps the device will not even recognize this language as its default locale and just use es for Spanish.
Can someone help?
Many devices ship with a limited selection of languages in the settings menu, but can actually be set to any system locale using an app such as LocaleSwitch.
It should be pretty easy to test whether Basque is supported by adding a custom locale in LocaleSwitch and then adding the resource folder to see if the system loads the resources from this folder automatically.
Finally, Gingerbread 'support' for Catalan may only reference the inclusion of android.R values since 2.3, though I can't see them in the framework repository.
Actually not all languages are documented at Android docs and many brands did your custom version of Android which may change its list, but be sure that if a device has Catalan and/or Basque suports it will use ISO standard, and the values will got rigth as it is converted with string comparision.
Maybe it would be a good choice to put a handed changer if you got that most devices do not have this support on your tests.
The thing is, if the language is not listed in the language selection list on the device, the resources can never be used as the device can never be put in this configuration by the user.
On the other hand, if the device allows you to select Basque, it will be using this format, and your resources will be used.
We can now create our "values-eu-rES" folder and have our app in Basque, Android Lollipop has made it.
We can create a folder
Basque strings ->
value-eu [Basque]
another folder
Catalan strings ->
value-ca [Catalan]
Adding a new language in LocaleSwitch, you need to type the ISO 639-1 code. For instance, if you want to switch to basque you need to enter "eu". Afterwards, you will see the new locale as "vasco".
That makes me think that basque locale is supported by android.
I am very new for developing the multi-language oriented Android APP. This is the first time i am going to support my app in multi-support language app. I need some clarification for developing the multi-language support app. Already i have some ideas before initiate the development.
Single APK with Localization like will make the multiple String.xml and include it in inside of the app and based the member selection of language its automatically invokes and works.
All language strings values will retain in app server (back-end) and will raise the Rest-API request and get those values and change it inside of the entire app (all screens) if member click and change the language inside of the app.
Main concern is if anything needs to change in future then Idea2 is best way. We will just change in back-end side it will be appeared in client side. But if we are going Idea1 and wants to change then we need to put the new build only.
Which one is best approach and recommended way to develop?
You will need to create different String.xml depending the languages you want to target as JDenais says, in my app i have the following
for example the first arab string consist in the same as Strings.xml but with all in arab, now, you only need to call one string in your xml files and it will just select where to grab depending on the phone language. Or in default the language from where the app was downloaded by google play, in fact, they are all the same strings.xml , so you dont need to specify which one you want to pull the translated text from, just replicate your main strings.xml in your other strings.xml and then the phone will decide where to pull the data.
Also please read the official doc on how to accomplish this https://developer.android.com/training/basics/supporting-devices/languages
Also please check the language ISO Codes here
What is the list of supported languages/locales on Android?
All your texts should be packaged in the APK in different String.xml files. Forget about receiving texts from a backend. It would be a lot of extra work for limited gain and with added risks of failure.
The framework takes care of selecting the appropriate string.xml file and offers support for needed use cases like plurals.
right click the values folder and choose new-> values resource file -> locale -> choose the language you want and name it strings.
copy the strings from the original string file to the new file and change them to the new language just the strings
make sure that the view xml files have their text set as "#string/the_name of the string" not hard coded
Our client application has means of updating a "language file" from a server occasionally. Yet it seems quite a challenge to support it on android..
I tried using inflate( XmlPullParser, ... ) but later found it doesn't support non-binary XML files.
The following are given:
Our app uses #string/resource_id resources to support languages. Basically it supports English, but the requirement is to provide language resources dynamically. That is, if we need to support Greek, or provide a change to the Greek language texts, we should be able to provide that on runtime.
So, on runtime our app connects a service and downloads an XML file, with syntax similar to string.xml in the current language.
What remains is how to change the text resources in the application in a sane manner (not one by one..)
I tried using inflate(with the XmlPullParser parameter) but it seems to be intended for use with binary pre-compiled XML files. To use that it would require to binarize the XML before hand, and that would be less compatible, not to say that aapt.exe tool is less documented, especially in my case.
So, any idea?
Don't know if it can be done everywhere in Android but instead of using native resources reference, maybe you can use the Java Properties class and using the device locale configuration to retrieve the wanted strings programmatically?
am wondering if is possible to use a feature on my app that can translate the app to other languages so the user can select through a list of languages so as he can read the app even if he doesnt speak English, thanks a lot
If you use the framework's localization facilities, this will happen automatically based on the user's language setting on their device
http://developer.android.com/guide/topics/resources/localization.html
Basically, instead of using string literals in your code (ie. txt.setText("Something") or android:text="Something"), you create these in your strings.xml file and use the automatically created reference id's.
res/values/strings.xml:
<string name="something">Something</string>
Then, you create alternate res/values folders for the other languages you support and create a similar strings.xml file there.
res/values-es/strings.xml
<string name="something">Algo</string>
Then your layouts and codes would have txt.setText(R.string.something) or android:text="#string/something".
You can do the same thing for drawable, layout, menu, etc.
"to use a feature on my app that can translate the app to other languages"
I do not think such feature exist from Google. But if you write the app according Google's localization guide then you can use our Nativer app, which is designed exactly for that. It takes you language resources - translates with a machine and then let's the crowd to correct it. All these happens in runtime - so you do not need to bother when the language translation finished by the crowd. You can find further info here transround.com
Peter