Giter Club home page Giter Club logo

Comments (5)

tfonteyn avatar tfonteyn commented on June 24, 2024 1

I can't reproduce, so I will need to dig into this deeper.

first notes:

From crash file:

"ANDROID_VERSION": "12"
"SDK_INT": 31,
"SECURITY_PATCH": "2021-10-05"
"locale": "zh_CN_#Hans"
"userSetLocale": false

java.util.MissingResourceException: Couldn't find 3-letter language code for zz
at java.util.Locale.getISO3Language(Locale.java:1742)
at com.hardbacknutter.nevertoomanybooks.utils.Languages.createLanguageMappingCache(Unknown Source:53)
at com.hardbacknutter.nevertoomanybooks.utils.Languages.getISO3FromDisplayName(Unknown Source:17)
at com.hardbacknutter.nevertoomanybooks.utils.AppLocaleImpl.getLocale(Unknown Source:42)
at com.hardbacknutter.nevertoomanybooks.settings.SettingsViewModel.init(Unknown Source:66)

java/util/Locale.java:
String lang = baseLocale.getLanguage();
String language3 = ICU.getISO3Language(lang);
if (!lang.isEmpty() && language3.isEmpty()) {
// END Android-changed: Use ICU.
throw new MissingResourceException("Couldn't find 3-letter language code for "
+ lang, "FormatData_" + toString(), "ShortLanguage");
}

so lang=="zz" comes from: baseLocale.getLanguage()

In my tests, the Locale for "zh_CN_#Hans" and the R.array.pv_ui_language values are all passing the above without a problem.

private void createLanguageMappingCache(@NonNull final Context context,
                                        @NonNull final Locale locale) {
    final SharedPreferences cacheFile = getCacheFile(context);

    // just return if already done for this Locale.
    if (cacheFile.getBoolean(LANG_CREATED_PREFIX + locale.getISO3Language(), false)) {
        return;
    }
    final SharedPreferences.Editor ed = cacheFile.edit();
    for (final Locale loc : Locale.getAvailableLocales()) {
        ed.putString(loc.getDisplayLanguage(locale).toLowerCase(locale),
                     loc.getISO3Language());
    }

so we're crashing in either

 locale.getISO3Language()

or

loc.getISO3Language()

The "locale" is "zh_CN_#Hans" (the userLocale as coming from up the stacktrace)
So we must be crashing in the "loc"... which is coming from "Locale.getAvailableLocales()" and this is from the device OS.

from nevertoomanybooks.

CloneWith avatar CloneWith commented on June 24, 2024 1

This version works properly. Thanks!

from nevertoomanybooks.

tfonteyn avatar tfonteyn commented on June 24, 2024 1

it confirms the issue was in the OS as installed by the vendor. Good to know. Thanks for the feedback!

from nevertoomanybooks.

tfonteyn avatar tfonteyn commented on June 24, 2024

ok, I cannot be sure, but I think I can prevent a crash if my reasoning above is correct.
I'll create a "6.0.1" version for you to test with. I'll upload it later today and notify you of course.

from nevertoomanybooks.

tfonteyn avatar tfonteyn commented on June 24, 2024

I uploaded 6.0.1

It has protection against the MissingResourceException by doing a fallback from the iso-3 to an iso-2 code.

It's safe to install on top of the 6.0.0 and later release will install on top of this 6.0.1.

Please give this a try and let me know the results.

from nevertoomanybooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.