Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using strings from @android:string

Tags:

android

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.

like image 456
mario595 Avatar asked Oct 01 '22 11:10

mario595


1 Answers

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

like image 73
Matt Antonelli Avatar answered Oct 05 '22 12:10

Matt Antonelli