Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization for Russian in Android

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.????????;
like image 849
enginar Avatar asked Jun 07 '12 11:06

enginar


1 Answers

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")
like image 130
Kazekage Gaara Avatar answered Oct 01 '22 07:10

Kazekage Gaara