androidxmllocalization

My app's language is not changing after changing the device language


I am translating my app to the Marathi language. I've made the value-mr-rIN/strings.xml for the Marathi language. When I change my device language to Marathi the app still uses the default strings.xml which is English instead of using the values-mr-rIN/strings.xml. What's the problem? I tried testing it on other devices still it shows English strings. I am pasting the code below

values/strings.xml

 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <string name="app_name">App name</string>
 <string name="test">this is a test</string>
 </resources>

values-mr-rIN/strings.xml

 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <string name="app_name">अॅप नाव</string>
 <string name="test">हे एक चाचणी आहे</string>
 </resources>

Solution

  • A single line of code in gradle was causing this issue.

    defaultConfig {
        ..
        resConfigs "en"
    }
    

    The above line in gradle means use only English language resource. Which is used to save space by removing other language resources from the app. I changed it to..

     defaultConfig {
        ..
        resConfigs "en" ,"mr"
    }
    

    Now it uses English or Marathi resources with respect to the device language.