Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3cac67c0 authored by Roozbeh Pournader's avatar Roozbeh Pournader Committed by Android (Google) Code Review
Browse files

Merge "Load Portuguese and German hyphenation in Hyphenator"

parents 40aa9f1b a1c0a82b
Loading
Loading
Loading
Loading
+31 −5
Original line number Diff line number Diff line
@@ -72,10 +72,20 @@ public class Hyphenator {
                return result;
            }

            // TODO: Convert this a proper locale-fallback system
            // If there's a variant, fall back to language+variant only, if available
            final String variant = locale.getVariant();
            if (!variant.isEmpty()) {
                final Locale languageAndVariantOnlyLocale =
                        new Locale(locale.getLanguage(), "", variant);
                result = sMap.get(languageAndVariantOnlyLocale);
                if (result != null) {
                    sMap.put(locale, result);
                    return result;
                }
            }

            // Fall back to language-only, if available
            Locale languageOnlyLocale = new Locale(locale.getLanguage());
            final Locale languageOnlyLocale = new Locale(locale.getLanguage());
            result = sMap.get(languageOnlyLocale);
            if (result != null) {
                sMap.put(locale, result);
@@ -83,9 +93,9 @@ public class Hyphenator {
            }

            // Fall back to script-only, if available
            String script = locale.getScript();
            final String script = locale.getScript();
            if (!script.equals("")) {
                Locale scriptOnlyLocale = new Locale.Builder()
                final Locale scriptOnlyLocale = new Locale.Builder()
                        .setLanguage("und")
                        .setScript(script)
                        .build();
@@ -142,6 +152,11 @@ public class Hyphenator {
        {"en-UM", "en-US"}, // English (United States Minor Outlying Islands)
        {"en-VI", "en-US"}, // English (Virgin Islands)

        // For German, we're assuming the 1996 (and later) orthography by default.
        {"de", "de-1996"},
        // Liechtenstein uses the Swiss hyphenation rules for the 1901 orthography.
        {"de-LI-1901", "de-CH-1901"},

        // Norwegian is very probably Norwegian Bokmål.
        {"no", "nb"},

@@ -166,7 +181,18 @@ public class Hyphenator {
        sMap.put(null, null);

        // TODO: replace this with a discovery-based method that looks into /system/usr/hyphen-data
        String[] availableLanguages = {"en-US", "es", "eu", "hu", "hy", "nb", "nn", "und-Ethi"};
        String[] availableLanguages = {
            "de-1901", "de-1996", "de-CH-1901",
            "en-US",
            "es",
            "eu",
            "hu",
            "hy",
            "nb",
            "nn",
            "pt",
            "und-Ethi"
        };
        for (int i = 0; i < availableLanguages.length; i++) {
            String languageTag = availableLanguages[i];
            Hyphenator h = loadHyphenator(languageTag);