Fix plurals in i18n sample (and others). There were two problems:
1) the I18N sample used en_US as the default locale in the annotation, but
we only had en in the locale list
2) the matched locale needed to be set to what we computed for the default
locale from the annotation
Patch by: jat
Review by: fabbott (TBR)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6297 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java b/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java
index 686ce09..2133fd6 100644
--- a/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java
+++ b/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java
@@ -22,7 +22,7 @@
* Internationalized messages used by {@link MessagesExampleController}.
* Used to demonstrate plural forms support.
*/
-@DefaultLocale("en_US")
+@DefaultLocale("en")
public interface PluralMessages extends Messages {
@DefaultMessage("You have {0} trees.")
@PluralText({"one", "You have one tree."})
diff --git a/samples/i18n/war/I18N.html b/samples/i18n/war/I18N.html
index 24ba7d5..c6dc031 100644
--- a/samples/i18n/war/I18N.html
+++ b/samples/i18n/war/I18N.html
@@ -191,7 +191,7 @@
are included in the source file via annotations.
</p>
<pre class="code">
-@DefaultLocale("en_US")
+@DefaultLocale("en")
public interface MyMessages extends Messages {
@DefaultMessage("You have {0} trees.")
@PluralText({"one", "You have one tree."})
diff --git a/user/src/com/google/gwt/i18n/rebind/AbstractResource.java b/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
index 8c28605..3a81b23 100644
--- a/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
+++ b/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
@@ -51,10 +51,10 @@
* Exception indicating a required resource was not found.
*/
public static class MissingResourceException extends RuntimeException {
+ private String during;
private String key;
private String method;
private List<AbstractResource> searchedResources;
- private String during;
public MissingResourceException(String key,
List<AbstractResource> searchedResources) {
@@ -96,9 +96,9 @@
private List<AbstractResource> list = new ArrayList<AbstractResource>();
- private Set<AbstractResource> set = new HashSet<AbstractResource>();
-
private Map<String, PluralForm[]> pluralForms = new HashMap<String, PluralForm[]>();
+
+ private Set<AbstractResource> set = new HashSet<AbstractResource>();
@Override
public boolean add(AbstractResource element) {
@@ -338,7 +338,7 @@
return key;
}
- private final GwtLocale matchLocale;
+ protected GwtLocale matchLocale;
private Set<String> keySet;
@@ -380,6 +380,10 @@
}
/**
+ * Get a key.
+ *
+ * @param key key to lookup
+ * @return the string for the given key or null if not found
* @see java.util.ResourceBundle#getString(java.lang.String)
*/
public final String getString(String key) {
diff --git a/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java b/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java
index b608adb..b2facf8 100644
--- a/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java
+++ b/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java
@@ -436,6 +436,7 @@
+ clazz.getQualifiedSourceName() + " doesn't match " + locale);
return;
}
+ matchLocale = defLocale;
for (JMethod method : clazz.getMethods()) {
String meaningString = null;
Meaning meaning = method.getAnnotation(Meaning.class);