Author: fabb...@google.com
Date: Mon Jun 15 19:57:26 2009
New Revision: 5562

Modified:
    wiki/DefaultLocaleBinding.wiki

Log:
Edited wiki page through web user interface.

Modified: wiki/DefaultLocaleBinding.wiki
==============================================================================
--- wiki/DefaultLocaleBinding.wiki      (original)
+++ wiki/DefaultLocaleBinding.wiki      Mon Jun 15 19:57:26 2009
@@ -13,7 +13,7 @@

  = Usage Specification =

-I propose adding configuration property to I18N.gwt.xml, for  
default.locale.  It's a configuration property because it isn't used for  
permutations; indeed, it shouldn't ever have multiple values.  This would  
be set to "default" by I18N.gwt.xml, but should be reset by user modules to  
whatever locale they want to have as their default.
+I propose adding a new XML element, `<set-property-fallback  
name="_propname_" value="_fallbackvalue_"/>`.  I18N.gwt.xml would set the  
fallback for `locale` to "default" by I18N.gwt.xml, but should be reset by  
user modules to whatever locale they want to have as their default.

  So, I18N.gwt.xml would contain:
  {{{
@@ -21,27 +21,37 @@
    <!-- 'default' is always defined, but might not be set if            -->
    <!-- default.locale is used to specify an actual locale as default.  -->
    <define-property name="locale" values="default" />
-  <define-configuration-property name="default.locale"  
is-multi-valued="false"/>
-  <set-configuration-property name="default.locale" value="default"/>
+  <set-property-fallback name="locale" value="default"/>
  }}}

  And my hypothetical app's .gwt.xml would contain:
  {{{
    <extend-property name="locale" values="fr_CA,de" />
-  <set-configuration-property name="default.locale" value="fr_CA" />
+  <set-property-fallback name="locale" value="fr_CA" />
  }}}

  = Implementation Requirements =

-The `AbstractLocalizableImpleCreator` code has to recognize generators  
that operate only on "default," and decide based on whether  
`default.locale` is or is not set and whether "default" is or is not in the  
locales list whether and when to run a given generator; in this example,  
the "fr_CA" permutation would run generators that run on all locales,  
on "fr_CA" _or_ on "default".  This requires access not to the defined  
values (from `define-property` and `extend-property`), but to the set  
values, which is currently inaccessible.
+The fallback value would be stored in a new filed of `BindingProperty`,  
with a public getter, default setter, and default value of "".  The  
interesting changes happen in the property provider, which would use a  
template syntax in the property provider !JavaScript and  
`getPropertyProvider()` would do template substitution, so that a property  
provider of

-More interesting changes happen in the property provider, which today can  
access only selection properties _with multiple values_.  The default  
locale should not be multiple, which is one reason I suggest it as a  
configuration property.  I propose giving property providers access to  
configuration properties as well, using a template syntax in the property  
provider !JavaScript and token substitution in `SelectionScriptLinker`,  
something like this fragment from I18n.gwt.xml:
+{{{
+      while (!__gwt_isKnownPropertyValue("locale",  locale)) {
+        var lastIndex = locale.lastIndexOf("_");
+        if (lastIndex == -1) {
+              locale = "/*-FALLBACK*/";
+          break;
+        } else {
+          locale = locale.substring(0,lastIndex);
+        }
+      }
+}}}

+Would become, for my hypothetical app,
  {{{
        while (!__gwt_isKnownPropertyValue("locale",  locale)) {
          var lastIndex = locale.lastIndexOf("_");
          if (lastIndex == -1) {
-              locale = "/*-GWTCONFIGPROPERTY(default.locale)-*/";
+              locale = "fa_CA";
            break;
          } else {
            locale = locale.substring(0,lastIndex);
@@ -49,6 +59,8 @@
        }
  }}}

-Note that this is a static substitution, because configuration properties  
have fixed value, unlike selection properties.  The substitution is used in  
generated the selection script, so a request for locale "jp" will fail to  
match known property values and be assigned "fr_CA" instead, as the  
requested `default.locale`.
+Note that this is a static substitution, at compile time.  The  
substitution is used in generated the selection script, so a request for  
locale "jp" will fail to match known property values and be  
assigned "fr_CA" instead, as the requested fallback.
+
+Also note that the substitution token is, if somehow seen by  
naive !JavaScript, merely a comment (much as JSNI is for Java code).  In  
this particular example, moreover, the token is inside a string literal, so  
a naive interpreter would merely see a very odd-looking (and in fact  
invalid) locale string.

-Also note that the substitution token is, if seen by naive !JavaScript,  
merely a comment (much as JSNI is for Java code).  In this particular  
example, moreover, the token is inside a string literal, so a naive  
interpreter would merely see a very odd-looking (and in fact invalid)  
locale string.
\ No newline at end of file
+Other uses might include setting a "default" logging configuration, which  
user modules could modify.  Not allowed by this scheme would be having a  
fallback that depended on any other input.  The fallback value _could_ be  
arbitrary !JavaScript, if the property provider were written to execute the  
extracted value (whether as a string or as non-quoted code).  I see few  
uses for that, but perhaps the "default" logging might depend on the  
client's subnet, or on a combination of query inputs for different logging  
areas.
\ No newline at end of file

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

Reply via email to