Change locale in android app (onto Hindi)


Creating multi languages support for the app with possibility to change language in App settings.

As for now everything works fine for English, Spanish, Franch, Russian languages, but doesn't work for Hindi and Chineese.

1) I specify the language name in original language but in the app instead of हिन्दी I can see "Hindi".


<?xml version="1.0" encoding="utf-8"?>

    <string-array name="languages">
        <item name="english">English</item>
        <item name="russian">Русский</item>
        <item name="spanish">Espagnol</item>
        <item name="russian">Français</item>
        <item name="chineese">中国</item>
        <item name="hindi">हिन्दी</item>
    <string-array name="languagesValues">
         <item name="english">en</item>
        <item name="russian">ru</item>
        <item name="spanish">es</item>
        <item name="russian">fr</item>
        <item name="chineese">zh-CN</item>
        <item name="hindi">hi</item>


2) End after selecting "Hindi" - actually default (English) is being selected.

<?xml version="1.0" encoding="utf-8"?>

    <string name="app_name">लकी बीनने</string>
    <string name="score">0000</string>
    <string name="settings">सेटिंग</string>
    <string name="start_button">प्रारंभ</string>
    <string name="about_button">के बारे में</string>
    <string name="about">लियोनिद द्वारा बनाया गया</string>
    <string name="feedback">प्रतिक्रिया भेजें </string>
    <string name="high_score">उच्च स्कोर के</string>
    <string name="score_set">स्कोर निर्धारित किया गया है \r\nमें:</string>
    <string name="game_over">खेल खत्म</string>


Saving locale in Preferences.

public class Settings extends PreferenceActivity {

    Locale myLocale;
    static boolean localeChanged;

    protected void onCreate(Bundle savedInstanceState) {

        // language changing
        Preference langPreference = getPreferenceScreen().findPreference(

    Preference.OnPreferenceChangeListener languageChangeListener = new OnPreferenceChangeListener() {

        public boolean onPreferenceChange(Preference preference, Object newValue) {

            switch (newValue.toString()) {
            case "en":

            case "ru":

            case "fr":

            case "es":

            case "zh-CN":

            case "hi":


            localeChanged = true;
            return true;

    // * manually changing locale/
    public void setLocale(String lang) {
        myLocale = new Locale(lang);
        Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        Configuration conf = res.getConfiguration();
        conf.locale = myLocale;
        res.updateConfiguration(conf, dm);
        Intent refresh = new Intent(this, Settings.class);

What is wrong? Is something wrong in my code, or in my device?


It depends on the device. Also, please check whether your device supports Hindi and Chinese languages by going to Settings --> Language & input.

Recent Tips

  1. How do I stop selenium automation if 20% or 1st 20 test cases test methods are failed?
  2. Sharepoint with silverlight app
  3. What's the best way to write robots.txt for github pages using multiple repos?
  4. Biopython: Cant use .count() for biopython
  5. How can I find out the token balance of an address?
  6. ref value is undefined in vue (modal, textarea, $refs)
  7. Azure - HDInsight Hbase Data Insertion Failed
  8. SignalR overwriting OnConnected(), OnDisconnected()
  9. DatePickerDialog displays with two borders
  10. "type 'double' is not a subtype of type 'int' in type cast" error in flutter. What should i do?
  11. hiding the autocomplete list when user click outside the textbox is not working as expected
  12. JSF IceFaces basic problem with redisplaying input value
  13. How to validate material ui TextField in reactjs?
  14. Go and MongoDB connection won't work with panic log "no reachable server"
  15. WordPress Posts Pagination Not Working
  16. F# sprintf won't print in interactive console
  17. Spring Integration get FTP files recursively with outbound-gateway
  18. Jade mixins not getting working from external file
  19. Can not access defined exports from the webpack bundle?
  20. Completely new to Node.js - API Programming
  21. Formatting Compare-Object Ouput
  22. Add dynamically added textbox value from User Control to main form
  23. Create a ByteBuf in Netty 4.0
  24. Is it possible to do computation before super() in the constructor?
  25. Q-learning Updating Frequency
  26. Wrong reload order when using Gulp and browserSync
  27. I use hugo build static page. But don't have content
  28. How to change background color and set bar colors based on conditional formatting in VBA?
  29. Problem when comparing two numeric values in SAS
  30. Is ACE reactor timer managment thread safe?