0

You can use strings in this way: " R.string.*" or in xml: "android:text=@strings/*" - right?

They all take their values out of a fixed file named strings where you put them all in right?

Let's say I have an app where there is the possibility to change language. Is there a way in which I can change that string file? Let's say have a strings file for English and strings for French or anything.. so i can still use the R.string.* and @string/* but I will get different values depends on the user choice?

user229044
  • 232,980
  • 40
  • 330
  • 338
Daniel Mendel
  • 506
  • 5
  • 17
  • I believe you're talking about localization. http://developer.android.com/guide/topics/resources/localization.html – A--C Dec 08 '12 at 19:41

1 Answers1

1

The Developer's Guide on Localization covers this.

In short use the same string names, but have different locale folders, like:

  • res/values/strings.xml for the default language
  • res/values-fr/strings.xml for French
  • res/values-ja/strings.xml for Japanese

The OS will load the appropriate language for R.string.hello for you.

Sam
  • 86,580
  • 20
  • 181
  • 179
  • Yes, Exactly what I was talking about – Daniel Mendel Dec 08 '12 at 19:56
  • You can also change the locale from user input to offer language support. Say the user selects French from a preference setting in your app, now no matter what Locale the device is actually in it will display the French strings with: [Changing Locale within the app itself](http://stackoverflow.com/a/4239680/1267661). – Sam Dec 08 '12 at 20:05
  • Thank you sam again, but i already found out about it by myself, This is what i was looking for... Yet again I am surprised how easy it is to develop for android :D – Daniel Mendel Dec 08 '12 at 20:16