2

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. Commented 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 Thorstensen Commented Jan 3, 2013 at 5:43

2 Answers 2

1

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> 
Sign up to request clarification or add additional context in comments.

2 Comments

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.
android support hindi from 2.3 , put values in values-hi folder
0

for that you need proper font .ttf file. U have to copy it in your project asset folder than By using Typeface you can fix your own font...

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.