How can I create a multilingual android application?
Yes, there is a recommended way to manage multiple languages
Multilanguage support is easy done for android. Create a new values directory for the language with the suffix of the language code. For german: values-de or french: values-fr than copy your string.xml into that and translate each entry. Thats all you need.
Do android support multiple languages?
Providing you follow the recommendations, detecting which language the user prefers is automatic.
Have a read of this:
http://developer.android.com/guide/topics/resources/localization.html
make multi language android application
From my observations, weird behaviour was affecting only Activity titles, and I found that I was setting translations of activity titles in Manifest file. Only these translations were misbehaving. All other dynamically set translations were working fine.
So, to fix the problem, I removed all activity labels from Manifest file, then set activity titles in onCreate method as below:
getSupportActionBar().setTitle(R.string.title_activity_followers);
Problem solved.
Android : How can i make my application multilingual?
The thing that you need to do is to create new folders in your res
folder.
Example : If you need to add support to spanish and italian you need to do it like this :
res folder
1.1 values
1.2 values-es // spanish
1.3 values-it // italian
And after that you need to create string.xml
files in values-es
and values-it
. And in all files you just need to create all string which you want to use like this :
<string name="title">Title</string> // in values folder
<string name="title">Title in Spanish</string> // in values-es folder
and etc.
And after that you can use these string as :
TextView text = (TextView) findViewById(R.id.textView);
text.setText(getString(R.string.title));
And this should work.
Multiple Language Support Android APP
You will need to create different String.xml depending the languages you want to target as JDenais says, in my app i have the following
for example the first arab string consist in the same as Strings.xml
but with all in arab, now, you only need to call one string in your xml files and it will just select where to grab depending on the phone language. Or in default the language from where the app was downloaded by google play, in fact, they are all the same strings.xml , so you dont need to specify which one you want to pull the translated text from, just replicate your main strings.xml
in your other strings.xml
and then the phone will decide where to pull the data.
Also please read the official doc on how to accomplish this https://developer.android.com/training/basics/supporting-devices/languages
Also please check the language ISO Codes here
What is the list of supported languages/locales on Android?
Enabling multi language support for android application
Just forget everything and just implement the below code Snippet
Inside your build.gradle file
defaultConfig
{
resConfigs "en", "ar"
}
And inside your activity:
@Override
public void onClick(View view)
{
switch(view.getId())
{
case R.id.buttonEnglish:
updateLanguage("en");
break;
case R.id.buttonArabic:
updateLanguage("ar");
break;
}
}
@Override
public void recreate()
{
if (android.os.Build.VERSION.SDK_INT >= 14)
{
super.recreate();
}
else
{
startActivity(getIntent());
finish();
}
}
private void updateLanguage(String language)
{
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
SharedPreferences languagepref = getSharedPreferences("language",MODE_PRIVATE);
SharedPreferences.Editor editor = languagepref.edit();
editor.putString("languageToLoad",language);
editor.apply();
recreate();
}
How can I create a multilingual android application for right to left languages?
Official support was introduced in Android 4.2, see RTL Layout Support. You can query whether it is being used through enter link description here.
You can either try and use the same layout in all cases, or specify a specific layout in 'layout-ldrtl'.
As per your example, if you're using the RelativeLayout you need to use the android:layout_alignParentStart attribute, rather than the android:layout_alignParentLeft to shift your label from left to right automatically.
Related Topics
Android Location Manager, Get Gps Location ,If No Gps Then Get to Network Provider Location
Android: Integer from Xml Resource
How to Use Android Canvas to Draw a Rectangle with Only Topleft and Topright Corners Round
One Onclickhandler for Multiple Buttons
How to Compile a Static Library Using the Android Ndk
How to Get Add to Home Screen Pop Up on Site Open in Mobile Browser
Broadcast Receiver Won't Receive Camera Event
Scaled Bitmap Maintaining Aspect Ratio
Android Application Class Lifecycle
Android Install on Device Failure [Install_Canceled_By_User]
Adjust Layout When Soft Keyboard Is On
Prevent Ussd Dialog and Read Ussd Response
Difference Between a Clickable Imageview and Imagebutton
How to Dynamically Set Headers in Retrofit (Android)
Android: Adding Static Header to the Top of a Listactivity
Mediastore - Uri to Query All Types of Files (Media and Non-Media)
Overridependingtransition Does Not Work When Flag_Activity_Reorder_To_Front Is Used