Reputation: 2160
My application supports some languages through Localization. When user selects any language, application is set for that particular language.
Application interacts with server. Problem is, when user is in some other language other than English, that language data is going to the server.
So, irrespective of the language user selected, always English language data should go to the server.
Please let me know how can I do it.
Example:
I have an array of strings stored in strings.xml for all the languages. When I pick any item from the array through spinner, it gives me particular language string item. What I want is, get English language strings irrespective of language user chosen.
Upvotes: 0
Views: 1117
Reputation: 336
Generally, xml resources should help you to modify the UI of your app. If you have to use some sort of constants to talk with your server, then, maybe it's not regarding the strings.xml files.
You could store those server-values in other ways and location.
EDIT TO RESPOND: I get it now. You could create a specific string.xml file for you spinner (or whatever you want), maybe named strings_for_spinner, and inside you enter values that are nowhere else already defined. In that way, the system is forced to use those strings (and, in your case, in english language).
Upvotes: 0
Reputation: 283
I thought this would be a solution: Load language specific string from resource? But it's tested and doesn't seem to work. A naive solution is to add the strings you want to send to the server in English to all string.xml files in all languages and then call these strings when you need to send them to the server, or simply have constants with the english strings in your code:
public static final String STRING_TO_SEND_TO_SERVER = "your_string_in_English"; // Use this string to send to server and the strings from the strings.xml file for your UI.
Upvotes: 1
Reputation: 3213
You can use the values
folder: the strings contained in it are always use per default.
You then just have to remove the strings you don't want to use for the others languages from the strings
file in their respective folder. Your app will then take the one in your values
folder, which will be in english.
Hope it helps.
Upvotes: 0