8261179: Norwegian Bokmål Locale fallback issue

Reviewed-by: joehw
This commit is contained in:
Naoto Sato 2021-02-05 18:15:40 +00:00
parent 0218917109
commit 4a1814cbf0
2 changed files with 42 additions and 21 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -2890,15 +2890,17 @@ public abstract class ResourceBundle {
}
if (language.equals("nb") || isNorwegianBokmal) {
List<Locale> tmpList = getDefaultList("nb", script, region, variant);
// Insert a locale replacing "nb" with "no" for every list entry
// Insert a locale replacing "nb" with "no" for every list entry with precedence
List<Locale> bokmalList = new LinkedList<>();
for (Locale l : tmpList) {
bokmalList.add(l);
if (l.getLanguage().isEmpty()) {
for (Locale l_nb : tmpList) {
var isRoot = l_nb.getLanguage().isEmpty();
var l_no = Locale.getInstance(isRoot ? "" : "no",
l_nb.getScript(), l_nb.getCountry(), l_nb.getVariant(), null);
bokmalList.add(isNorwegianBokmal ? l_no : l_nb);
if (isRoot) {
break;
}
bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
l.getVariant(), null));
bokmalList.add(isNorwegianBokmal ? l_nb : l_no);
}
return bokmalList;
} else if (language.equals("nn") || isNorwegianNynorsk) {