Android, retrieves from different values folder - android

I am a newbie for android and really need you all helps to complete my task ^^. I am currently doing a project which is quite similar to android localization. However, there is another native language that is not stated down in language or a language-region combination that provided by the android setting. Is there any other ways that i can do to make the application retrieve different strings when different language selected?
I have try to create different names of values folder but it doesn't work when the folder named as "values-penan".
Thanks if anyone could help!

Related

Converting hard coded strings to string resources

So, i kind of created a monster. Built an android game for few years and used lots of hardcoded strings. Now i want to support different languages. My questions - is there an automatic way to create these resources?
for example tell Android studio for all the "hard coded" warnings apply extract string resource.
I aw aware of the inspect code that show you localization warnings, i am looking for a way to automate the fix
AFAIK, it's not possible to fix that automatically. You need to press Alt+Ctrl+Shift+i and type hardcoded strings. After completion of the finding process, manually create them in strings.xml.
I am attaching a link to site that will convert your string.xml to different language you want and then download translated string.xml in your stings folder, it will translate each string step by step, if this is what you want, hope it helps
https://asrt.gluege.boerde.de

android package naming when using different localization assets

Suppose I have an android app, say com.acme.game
This app is using different assets to achieve localization.
What will be the best strategy for building this App (apk) ?
Should I create separate projects for each "locale" and name it com.acme.game.en, com.acme.game.rus... accordingly,
or there is a better way without any duplication?
You can keep a single package name and just add different assets for various locales in appropriate folders. Read more about it here

Convert android project to multi-language

I have an Android project that I developed one year ago. I didn't think in do the project multi-language and now I need support it.
There are any easy way to detect all strings and generate the XML file? Or I need modify the project string for string?
The project is developed in Eclipse.
Android provides a very simple way to localize apps: string resources.
You need to provide several strings.xml files.
Each in a directory called /res/values-xy, where xy is the language (i.e.: es, fr, en, de, it, ...).
Then just refer these strings in your project, like R.string.my_string_name (in Java) or #string/my_string_name (in xml)
For reference: http://developer.android.com/training/basics/supporting-devices/languages.html
[EDIT]
Same goes for arrays: just use /res/values-xy/arrays.xml
Note: the names strings.xml and arrays.xml are just conventional ones can be changed to anything you like better.
AFAIK You need to modify the strings in your project manually. If you have hard-coded strings in your layouts then you can use Lint to find out all the hard-coded strings. Put them then into values/strings and the translation should go to the respective folder of each language.
EDIT:
If you're running Eclipse you can use the search feature to help you track all your hard-coded String. Check this topic

Using strings from #android:string

I am a bit noob in Android and recently I found out that I can use the predefined string that Android provides as #android:string/cancel or #android:string/ok. At first I thought it was a good idea to use them because is a way to reuse code, but now I am not so sure about that.
What if somebody with a device configured with a language that I don't support install my app?
I assume that the app will use a default language, probably english, but those string from #android:string will get translated to the user's language, so he will end up with a mix of languages.
It this true? What do you think about use #android:string?
Thanks!
EDIT: Apparently my question hasn't been understood properly. I am NOT asking about how to support different languages. My question is about the convenience of use strings defined on #string:android, if it is correct to use them or can be lead to undesirable situation like a mix up of languages in the same application.
To ensure that your strings are appearing properly on devices configured with different languages, you'll want to create different values directories for different languages. For example, your default string values would be kept under values/strings.xml and French string values would be kept under values-fr/strings.xml.
The Android Developer website gives you plenty of information for supporting different languages in your application. http://developer.android.com/training/basics/supporting-devices/languages.html
The android: values (strings, icons, themes, etc.) will differ between devices and Android versions. If you want to use them, it's safest to copy them into your project. So for strings, you wouldn't have to worry about partial translation.
In the ressource folder of your app (res), ther is a folder "values" in it, and in this folder is the string ressource xml (strings.xml).
Usually, your app selects the strings from this file.
But you can add other value folders like this: Just create a new folder and name it "values-countryCode", for example "values-ch" for Switzerland ;)
Your app automaticly chooses the right string ressource, depending on your device's langague settings. If the langague of your device isn't available, it just takes the sting ressource of the default "values" folder.
A list if the country-codes is here.
Further information can be found here.
Hope I helped, and this is what you're looking for!

How to use multiple languages in android

I want to give my user an option to select his language and according to his selection i want to display language.
Can my android app support multiple languages. How to do that?
What you are referring to is termed Localization
You can do it under your resource folder. For example, let's say you want to have language support for France. For such cases, you can do it by creating a folder res/values-fr/strings.xml. In addition, you can have a folder called res/drawables-fr, as well.
You can check out more on these sites.
http://developer.android.com/resources/tutorials/localization/index.html
http://www.icanlocalize.com/site/tutorials/android-application-localization-tutorial

Categories

Resources