Java Code Examples for sun.util.locale.BaseLocale#getVariant()

The following examples show how to use sun.util.locale.BaseLocale#getVariant() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceBundle.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 2
Source File: ResourceBundle.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 3
Source File: ResourceBundle.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            if (region.equals("TW") || region.equals("HK") || region.equals("MO")) {
                script = "Hant";
            } else if (region.equals("CN") || region.equals("SG")) {
                script = "Hans";
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            if (script.equals("Hans")) {
                region = "CN";
            } else if (script.equals("Hant")) {
                region = "TW";
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 4
Source File: ResourceBundle.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 5
Source File: ResourceBundle.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 6
Source File: ResourceBundle.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 7
Source File: ResourceBundle.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 8
Source File: ResourceBundle.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 9
Source File: ResourceBundle.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 10
Source File: ResourceBundle.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 11
Source File: ResourceBundle.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 12
Source File: ResourceBundle.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().isEmpty()) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.isEmpty() && !region.isEmpty()) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 13
Source File: ResourceBundle.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 14
Source File: ResourceBundle.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 15
Source File: ResourceBundle.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 16
Source File: ResourceBundle.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 17
Source File: ResourceBundle.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}
 
Example 18
Source File: ResourceBundle.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected List<Locale> createObject(BaseLocale base) {
    String language = base.getLanguage();
    String script = base.getScript();
    String region = base.getRegion();
    String variant = base.getVariant();

    // Special handling for Norwegian
    boolean isNorwegianBokmal = false;
    boolean isNorwegianNynorsk = false;
    if (language.equals("no")) {
        if (region.equals("NO") && variant.equals("NY")) {
            variant = "";
            isNorwegianNynorsk = true;
        } else {
            isNorwegianBokmal = true;
        }
    }
    if (language.equals("nb") || isNorwegianBokmal) {
        List<Locale> tmpList = getDefaultList("nb", script, region, variant);
        // Insert a locale replacing "nb" with "no" for every list entry
        List<Locale> bokmalList = new LinkedList<>();
        for (Locale l : tmpList) {
            bokmalList.add(l);
            if (l.getLanguage().length() == 0) {
                break;
            }
            bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
                    l.getVariant(), null));
        }
        return bokmalList;
    } else if (language.equals("nn") || isNorwegianNynorsk) {
        // Insert no_NO_NY, no_NO, no after nn
        List<Locale> nynorskList = getDefaultList("nn", script, region, variant);
        int idx = nynorskList.size() - 1;
        nynorskList.add(idx++, Locale.getInstance("no", "NO", "NY"));
        nynorskList.add(idx++, Locale.getInstance("no", "NO", ""));
        nynorskList.add(idx++, Locale.getInstance("no", "", ""));
        return nynorskList;
    }
    // Special handling for Chinese
    else if (language.equals("zh")) {
        if (script.length() == 0 && region.length() > 0) {
            // Supply script for users who want to use zh_Hans/zh_Hant
            // as bundle names (recommended for Java7+)
            switch (region) {
            case "TW":
            case "HK":
            case "MO":
                script = "Hant";
                break;
            case "CN":
            case "SG":
                script = "Hans";
                break;
            }
        } else if (script.length() > 0 && region.length() == 0) {
            // Supply region(country) for users who still package Chinese
            // bundles using old convension.
            switch (script) {
            case "Hans":
                region = "CN";
                break;
            case "Hant":
                region = "TW";
                break;
            }
        }
    }

    return getDefaultList(language, script, region, variant);
}