Is it possible to choose between two strings.xml files?

android, xml

Solution

it looks like you are simply trying to internationalize your app. android of course has a well-defined facility for this. create locale-specific values folders under `res` as

res/values-<locale>/strings.xml

and populate this file with the values according to the locale. for example,

res/values-fr_FR/strings.xml

for details, read the Android Localization page on the developer site.

Problem

I am currently working on an Android App, and have been for about six weeks. I just found out that it will also need to be run in a different language. All of my string resources are saved in the `strings.xml` file. What I was wondering, was if I could make a separate file, something like `strings2.xml`, and depending on what the user chooses, the program will choose either `strings.xml or strings2.xml` for all of the string references. This would be in my layout file, `main.xml`. ``` <Button android:id="@+id/more_parametersButton" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/more_parameters" /> ``` Then I would have 2 separate string files. strings.xml ``` <?xml version="1.0" encoding="utf-8" standalone="no"?> <resources> <string name="more_parameters">More Parameters</string> </resources> ``` and strings2.xml ``` <?xml version="1.0" encoding="utf-8" standalone="no"?> <resources> <string name="more_parameters">Mais Parâmetros</string> </resources> ``` It seems like this won't be possible, but if it is, I'd appreciate the info.

Original source