Treat @DefaultLocale as equivalent to "default" when determining preference
order.
Patch by: jat
Review by: rjrjr
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6693 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/i18n/rebind/AbstractResource.java b/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
index 51058a7..abaeb89 100644
--- a/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
+++ b/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
@@ -143,15 +143,21 @@
for (int i = 0; i < searchList.size(); ++i) {
derivedIndex.put(searchList.get(i), i);
}
- GwtLocale best = LocaleUtils.getLocaleFactory().getDefault();
+ GwtLocale defaultLocale = LocaleUtils.getLocaleFactory().getDefault();
+ GwtLocale best = defaultLocale;
int bestIdx = Integer.MAX_VALUE;
for (int i = 0; i < list.size(); ++i) {
GwtLocale matchLocale = list.get(i).getMatchLocale();
Integer wrappedIdx = derivedIndex.get(matchLocale);
if (wrappedIdx == null) {
- logger.log(TreeLogger.WARN, "Locale " + matchLocale
- + " not in searchlist " + searchList);
- continue;
+ // We had an @DefaultLocale for a locale not present in this
+ // permutation -- treat it as the default locale.
+ wrappedIdx = derivedIndex.get(defaultLocale);
+ if (wrappedIdx == null) {
+ // shouldn't happen
+ assert false : "No default locale in search list";
+ continue;
+ }
}
int idx = wrappedIdx;
if (idx < bestIdx) {