3

I have an android app which has 3 languages in res folder.

  • English
  • French
  • Chinese

I want my app to add another language at runtime in res folder and not by adding string xml files and recompile them.

How can i achieve this? I've search alot in google and no luck.

Thanks alot!!

3
  • You can't add something to the res folder at runtime. Commented Oct 24, 2012 at 6:08
  • So, is it possible to load string.xml in external location? Commented Oct 24, 2012 at 6:13
  • 1
    You can load all the strings from strings.xml but I don't see how would this benefit you as you still can't modify and write back the strings for the new language, so you would need to modify the text for each of the strings manually. Why(or for what) do you need to add the new language at runtime? And from where would the new strings.xml come? Commented Oct 24, 2012 at 6:20

2 Answers 2

1

I confirmed that this is not possible because all files in res folder are read-only

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

2 Comments

You could have a second source for strings and check programatically whether a string resource exists in resources before using this second source. The second source could be a map held in memory and loaded in at runtime.
@DavidCaunt can you please tell more about how to add 'second source'?
0

I'm facing the same problem and I will just get all strings from a (cached) remote file. The TextView text property will store an id and in the Activity.onCreate() method I'll programatically replace all TextViews.text strings with it's matched value from the current language file.

Comments

Your Answer

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