0

I was wondering if it's possible to load resources from strings.xml in raw xml resource. Example:

<root>
<element>@string/res1</element>
<element>@string/res2</element>
<element>@string/res3</element>
</root>

Is this possible?

If it's not possible, if I create a raw xml resource, do I have to provide multiple files for localization purposes?

1 Answer 1

2

Are you trying to use values declared in strings.xml in a file inside /raw/? Then no, that's not possible. If you want to internationalize your "raw" XMLs you can provide one for each of your supported languages in the appropriate folder (/raw-fr/, /raw-en/, etc). At least that's out of the box.

Alternatively, you can establish a template format and parse the raw XMLs in Java and fetch the appropriate string resource from there instead.

Sign up to request clarification or add additional context in comments.

4 Comments

Can you give an example of the second suggestion?
<element attribute="{!myString!}">{!myString2!}</element> You'd read the XML then replace all instances of {!*!} with the appropriate string from your resources.
Thank you for your reply. Is there any tutorial or example where I can read up on this?
I'm sure there are some tutorials floating around on general templating, but this seems a bit specific (and non-standard) for android...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.