5

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.

1
  • I think you should just try it out. Install your app and switch emulator language to an not supported one Commented Feb 27, 2014 at 14:16

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

This should be marked as the correct answer. Just a little thing to add: if the user is using a language that you haven't implemented in the app, Android will get the string files from the default (values/strings.xml) folder.
1

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.

Comments

0

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!

1 Comment

I forgot to say: Your app chooses the string ressource depending on the langague of your device. If there's no string ressource for your langague, it chooses the default "values" - folder.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.