Java – Android multi-language support without localization

Android multi-language support without localization… here is a solution to the problem.

Android multi-language support without localization

Hello, I am working on an Android project.

I want to provide multilingual support for my application.
I looked into this but found that almost everything is localized.

Is there a way to do this without localization?

My preference is to use localized or supported versions of language support.

I mean the user can switch languages in the app.

Can I do this for multiple value files?

Solution

Use this to change the language by code —

 Locale locale = new Locale("en_US");
 Locale.setDefault(locale);
 Configuration config = new Configuration();
 config.locale = locale;
 context.getApplicationContext().getResources().updateConfiguration(config, null);

Write the country code of the language instead of “en_US” any language you want … For example Japanese – “ja_JP” for Arabic – “ar” or check this link for country code –

http://code.google.com/apis/igoogle/docs/i18n.html

And create a folder in res/values-ja for Japanese or in res/values-ar for Arabic…

And make a string.xml file and put any language you want on your layout:
It will get the default language from the values folder, otherwise you need to get it manually, then it will get from your external folder values-ar etc, for example….

Arabic res/values-ar example —

<?xml version="1.0" encoding="UTF-8"?>
  <resources>
     <string name="spinner_label">تصفية حسب</string>
     <string name="app_name">2011 فرق</string> 
     <string name="search">بحث :</string>
  </resource>

Hope this helps…

Related Problems and Solutions