Alex Rivera | Logout

Localization for Russian in Android

Asked 2012-06-07T11:52:45.750
13

My application supports 4 languages. The user select their language. But this is not working for Russian.

if (dil.equals("eng")){
        Configuration c = new Configuration(context.getResources().getConfiguration());
        c.locale = Locale.ENGLISH;
        context.getResources().updateConfiguration(c,context.getResources().getDisplayMetrics());
        
    }
    else if (dil.equals("ger")){
        Configuration c = new Configuration(context.getResources().getConfiguration());
        c.locale = Locale.GERMAN;
        context.getResources().updateConfiguration(c,context.getResources().getDisplayMetrics());
        
    }
    else if (dil.equals("rus")){
        Configuration c = new Configuration(context.getResources().getConfiguration());
        c.locale = Locale.????????;
        context.getResources().updateConfiguration(c,context.getResources().getDisplayMetrics());
        
    }
    else
    {
        Configuration c = new Configuration(context.getResources().getConfiguration());
        c.locale = Locale.getDefault();
        context.getResources().updateConfiguration(c,context.getResources().getDisplayMetrics());
        
    }

I don't know what to do for Russian.

c.locale = Locale.????????;
Edit
Report

1 Answer

42

Using this constructor you can set your locale to Russian like this:

Locale myLocale = new Locale("ru","RU");

Here is a list of supported locales by Java. You can see that "ru" is supported , but not tested.

The documentation also says some times its better to give base localization and internationalization so I edited from

Locale myLocale =  new Locale("ru") 

to

Locale myLocale = new Locale("ru","RU")
answered 2012-06-07T12:12:12.880

Your Answer