How can I have more languages in an android app? - android

I want to set in my android app more languages : english, french, german,italian. That's mean that when I choose one of them in the app all the text from textviews, button..will appear in that language. How can I do that? Should I save the words from all app in a local SQlite database ? Can you provide me some examples? Thanks in advance.

All the techniques you need are covered in the Localization guide.

You can use the res/values/strings.xml in your ressource folder.
After that you can create multiple folders, e.g. "values-en" for the english strings.xml
or values-fr/strings.xml for french. Check this link.

Related

It is about reading XML file in android studio

If I have XML file and it was wrote in Arabic, but my application supports 2 languages (Arabic & English), is there any way to change the sentences in XML file to English when the user changes the language of the app?
I think Official Documentation is written in pretty well methodology -
So here I'm providing you that links -
Let me entitle it as -
Thing to be taken care of while you are developing an App with muti-language support
Localization Checklist
Writing style
XLIFF - XML Localisation Interchange File Format
Ps, First link is the parent of all, Go there - Its pretty interestring stuffs out there!
Everything you need is explained in the official Android Documentation.
You should create strings.xml for Arabic and English languages
You can create different XML files for different languages. The app/android will choose in condition to the system language which XML too choose.
You just have to create a new folder called values-ar in res/ where you put your Arabic strings.xml

Create Android app in multiple languages

I have submitted an Android app to Google Play and I see that I can create different descriptions for each language it supports. My question is: can I create a different APK for each language? Alternatively, how can I detect the user's preferred language, so that I can automatically activate that language for the user in the app?
Here is the official tutorial for localizing your app. :)
You can create a different apk for each language ( split-apk ) - but I would not recommend this. Better use the platform function for this and put your strings file in the right path ( values- ) - after this everything is automagically done
no just use the /res/values/strings.xml
for example to choose english language create a folder in same directory of values and call it values-en, for frensh values-fr and so on. the default language of the app is under values/
And if (for some reason) you still need to know witch is the devices language use
Locale.getDefault().getDisplayLanguage();

How does Android handle unsupported languages?

I've made an app that runs in multiple languages, but if the user runs it in an unsupported language, will it display the main one?
If it is the case, how can I make it display in English instead?
You are right.
Just put your english strings on the strings.xml file, so it will be loaded by default if no other language matches the phone lang.
Hope this helps.
if the user runs it in a not supported language, will it display the main one?
The default language, yes See the docs for detailed information.
Whenever the application runs in a locale for which you have not provided locale-specific text, Android will load the default strings from res/values/strings.xml. If this default file is absent, or if it is missing a string that your application needs, then your application will not run and will show an error.
how can I make it to display English instead?
Also see the docs for that, you should use english in the default strings.xml
How to Create Default Resources
Put the application's default text in a file with the following location and name:
res/values/strings.xml (required directory)
The text strings in res/values/strings.xml should use the default language, which is the language that you expect most of your application's users to speak.
Depends really what language are you using in your string.xml (main one). If there is no language case for what the user selects in the Settings, the app will load in the default values from the strings.xml
Language which you want to load by default then put that strings.xml
in values
folder without any suffix with values folder
In fact when you run your app, the app will check if the locale is available thanks to the string.xml contains in the value-locale folder. If nothing is found the string.xml in values is used so just put english traduction in your string.xml.
I hope to be clear.

Android Multilanguage support

I have android application developed in English language and also have content in English. Is this possible that all texts are converted in other language like in Chinese or Japanese, then How? some sample code or tutorial will help me lot.
I am able to get language selected through setting with code as follows.
Locale.getDefault().getDisplayLanguage()
The usual way to do this is to:
Enter your strings in a strings.xml file in the /res/values/ folder of your project. You can then define different localizations of your string file by added them to the localized /res/values/ folders. ( /res/values-jp/ or /res/values-en/ etc.)
See: Developer Android
We can also use translation api. Refer this Link
http://www.creatiosoft.com/how-to-use-microsoft-translation-api-in-android/

how to setup property in string.xml?

i want to create an application in android ,for two country like U.S. or Japan.
my problem is that ,In my login or Registration forms labels are designed for once and use for both senario(countries).
This make sence by String.xml file . but how can ?
If any body knows then please give me idea.
Thanks in advance.
Create sub folders for different locale in the res folder.
Example:
res/values
res/values-in
res/values-fr
Copy strings.xml into those folders. One file per folder.
After that, change the languages for each strings.xml in respective to the folder. e.g., values-in for Indonesia, values-fr for France, etc.
Read this guide to further more explanation:
Android Localization

Categories

Resources