Wednesday, September 26, 2018

android - localization of assets files



I have several html files in assets folder. How can I localize them? Is my only option to put some hardcode to pick the right file based on locale?


Answer



This isn't supported directly but here is what I have done...




Separate your files into groups by country code (like what you would do for normal resource files) and then create a localized string in each of your localized string.xml files called something like "prefix" (where prefix would be "en" for English for example).



Then when you build your asset filenames simple use something like getString("prefix") + "-" + ".



At least some variation of the above should work for you.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...