android - English/Spanish App: How do I set displayed values in spanish in values-es/strings but keep the values in English for the ifs checks in the app? -


i have folder values strings.xml in english , values-es folder string.xml in spanish. have fragment gets opened action bar set settings , store them in sharedpreferences, works fine in english. have lot of if's in app check set on share preferences words in english , in strings.xml in spanish want avoid changing ifs in app. tried doesn't work:

 <string-array name="music">         <item value="yes">si</item>         <item value="no">no</item>     </string-array> 

is there way similar? want user select "si" on preferences spinner when value spinner want retrieve "yes"

you should using constants value need save in shared preferences way language independent.

for example if have 2 radio buttons music naming on , off should create 2 constants

public static final int on = 1; public static final int off = 0; 

now on click of radio button should checking id of radio button , saving appropriate constant in shared preferences:

case: r.id.radio_on  //save on in shared preferences  break;  case: r.id.radio_off      //save off in shared preferences      break; 

then can check constants independent of language.


Comments