1

I' trying to localize an app to a language that is in the code set: ISO 639-3. This language is spoken in Australia and is called Gupapuyŋu.

In the directory tree, I have created: res/values-guf/strings.xml. However, no one of the localized strings is loaded:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">ABN Dhupuma</string>
    <string name="action_settings">Ŋäj</string>
    <string name="about">Nhämirri</string>
</resources>

Here's the code:

private void setLocaleGupapuyŋu() {
    Locale gupapuyŋu;

    Context con = getBaseContext();
    Resources res = con.getResources();

    if(BuildConfig.VERSION_CODE < Build.VERSION_CODES.LOLLIPOP) {
        //gupapuyŋu = new Locale("guf", "au");
        gupapuyŋu = new Locale("guf");
    } else {
        gupapuyŋu = new Locale.Builder()
                .setLanguage("guf")
                //.setRegion("au")
                //.setScript("lati")
                .build();
    }

    Log.v("Language", gupapuyŋu.getDisplayCountry());

    Locale.setDefault(gupapuyŋu);
    Configuration config = new Configuration();
    config.locale = gupapuyŋu;

    DisplayMetrics displayMetrics = con.getResources().getDisplayMetrics();

    res.updateConfiguration(config, displayMetrics);
}

Thanks guys and gals, appreciating the effort.

Ben
  • 3,012
  • 1
  • 21
  • 25
  • 1
    Is there a reason why you have to do this programmatically? Check out this post: http://stackoverflow.com/questions/2900023/change-language-programatically-in-android – Andrea Thacker Mar 12 '15 at 03:46
  • 1
    @dthacker Yes, because there is no way for the user to select Gupapuyŋu as a language preference in his/her device. Therefore, I need to have it as an app preference instead. Thanks for the link although it does not work as Gupapuyŋu is on the ISO 639-3. Thanks. – Ben Mar 12 '15 at 04:03

0 Answers0