I have application with internet access and don't want to store many string.xml
files for different languages.
What I want:
string.xml
with english strings.The question is how to change existing or add new string.xml
file in runtime?
Localization is the process of translating an application's resources into localized versions for each culture that the application will support.
In order to localize the strings used in your application , make a new folder under res with name of values-local where local would be the replaced with the region. Once that folder is made, copy the strings. xmlfrom default folder to the folder you have created. And change its contents.
Right click on it, then choose New ▸ Android Resource Directory. This opens the New Resource Directory window. From there, you can select the resource type and qualifiers you want to create. For localization of strings, add a new directory with a values resource type and a Locale qualifier.
Now I can see only solution:
string.xml
or downloaded resource)getString()
and getText()
to your own method getStringFromLocalization
TextView
, Button
and some other views with custom one and change there init and setText
methods.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With