问题
I have application with internet access and don't want to store many string.xml files for different languages.
What I want:
- Application contains only one
string.xmlwith english strings. - When user launches it - I see user's phone locale, and ask my own server for necessary language file. (resource keys will be the same)
- When new resource file comes, all interface should work with new file.
The question is how to change existing or add new string.xml file in runtime?
回答1:
You obviously cannot change, download or remove strings.xml at runtime
If you want to store locations, you will have to use SQLite storage to store translations.
similar:
How to modify strings.xml file at runtime
run time modification of strings.xml
回答2:
Now I can see only solution:
- Create some "localization proxy" that will return me necessary resource (from
string.xmlor downloaded resource) - Replace all
getString()andgetText()to your own methodgetStringFromLocalization - Override
TextView,Buttonand some other views with custom one and change there init andsetTextmethods.
回答3:
Overriding the standered resource/language using resource files which are complied time then your scarifying performance over customization. Do it only if u need this.
来源:https://stackoverflow.com/questions/9365328/can-localization-resources-be-downloaded-in-runtime