I am developing an Android app in English and Gujarati languages.The user will select which language he wants to use in the application itself. The problem here is that Android does not support Gujarati,Hindi or other Devnagari languages by default. Suppose i develop this by setting the fonts in the assets folder but the real problem for me is that if i want to add more such languages in the future,i do not want to change the code of my application,so how can i add more languages without changing the code?
2
- Create resource bundles and access them by locale. That's the usual approach to I18N with Java.duffymo– duffymo2012-10-21 18:10:33 +00:00Commented Oct 21, 2012 at 18:10
- Android support hindi from 2.3 version. You can use folder values-hi in res and can put your string files there as @Tobias Moe ThorstensenMGDroid– MGDroid2013-01-03 05:43:48 +00:00Commented Jan 3, 2013 at 5:43
Add a comment |
2 Answers
Create several res folders which you will name for instance res-fr and inside this folder store a string.xml file which will contain all of your strings. Import them in your application by using
getResources().getString(R.string.mystring); Remember to always use the same name for every strings, but change the content of each element:
English string.xml
<string name="welcome">Welcome to my application</string> and French string.xml
<string name="welcome">Bienvenue sur ma demande</string> 2 Comments
Akash Shah
this is fine but what to do about other languages.Android does not support Hindi,Gujarati,Tamil or other Indian languages by default.How come my phone will select the string.xml file when the language itself is not present in the device.
MGDroid
android support hindi from 2.3 , put values in values-hi folder