Revision: 6297
Author: j...@google.com
Date: Mon Oct  5 06:46:07 2009
Log: 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)

http://code.google.com/p/google-web-toolkit/source/detail?r=6297

Modified:
   
/trunk/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java
  /trunk/samples/i18n/war/I18N.html
  /trunk/user/src/com/google/gwt/i18n/rebind/AbstractResource.java
  /trunk/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java

=======================================
---  
/trunk/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java   
 
Mon Mar 17 16:53:10 2008
+++  
/trunk/samples/i18n/src/com/google/gwt/sample/i18n/client/PluralMessages.java   
 
Mon Oct  5 06:46:07 2009
@@ -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."})
=======================================
--- /trunk/samples/i18n/war/I18N.html   Thu Aug 27 21:33:04 2009
+++ /trunk/samples/i18n/war/I18N.html   Mon Oct  5 06:46:07 2009
@@ -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."})
=======================================
--- /trunk/user/src/com/google/gwt/i18n/rebind/AbstractResource.java    Mon  
Mar  2 23:51:53 2009
+++ /trunk/user/src/com/google/gwt/i18n/rebind/AbstractResource.java    Mon  
Oct  5 06:46:07 2009
@@ -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) {
=======================================
--- /trunk/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java Wed  
Jun 17 12:35:29 2009
+++ /trunk/user/src/com/google/gwt/i18n/rebind/AnnotationsResource.java Mon  
Oct  5 06:46:07 2009
@@ -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);

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to