0

I mean the name, not it's values, for example this:

<resources>
    <string name="magical_value_1">Lapin</string><br>
    <string name="magical_value_2">Poulet</string><br>
    <string name="magical_value_3">Saucisse</string><br>
</resources>

if i use String value1 = getResources().getString(R.string.magical_value_1); the result it's going to be Lapin, but I need a way to get "magical_value_1" (not Lapin) in a variable. I need to do this because of languages, I have a lot languages in my app,and their values changes, but the name(magical_value_1) it's the only thing that remains(regardless the language). thanks

user2580401
  • 1,840
  • 9
  • 28
  • 35
  • 1
    Did you read about supporting different languages http://developer.android.com/training/basics/supporting-devices/languages.html ? It sounds to me, that you're trying to support different languages, but is trying to do this the wrong way... – Darwind Oct 06 '13 at 00:10

3 Answers3

1

You should consider take a look to i18n android developer documentation.

ssantos
  • 16,001
  • 7
  • 50
  • 70
1

If you are trying make your apps to support multiple language. Here's some simple sample.

Let's say you are trying to make your apps to support france and english. You needs to create res/values/strings.xml for english (Be precisely, other language then france) and res/values-fr/strings.xml for france.

Inside res/values-fr/string.xml

<resources>
    <string name="magical_value_1">Lapin</string><br>
    <string name="magical_value_2">Poulet</string><br>
    <string name="magical_value_3">Saucisse</string><br>
</resources>

And inside res/values/string.xml

<resources>
    <string name="magical_value_1">Rabbit</string><br>
    <string name="magical_value_2">Chicken</string><br>
    <string name="magical_value_3">Sausage</string><br>
</resources>

To test it by changing your device language on settings.

edisonthk
  • 1,403
  • 16
  • 35
  • that is what i do, but not sure when I change a language different than english , doesn't work , but I have fixed now – user2580401 Oct 06 '13 at 17:50
0

See this answer.

tl;dnr:

getResources().getResourceEntryName(int resid);
Community
  • 1
  • 1
Buddy
  • 10,874
  • 5
  • 41
  • 58