Hi Jens,

Thanks for the idea, I tried it but it did not lead to a change. Looking a 
bit further into how the <set-property> and <extend-property> are handled 
that actually makes sense: set-property modifies only the *allowed* values 
of the property, but the code generating the values 'locale' is checked 
again looks at the *possible* values, which are controlled by 
extend-property.

Ultimately I now went with a custom generator, which looks like this:

import java.util.SortedSet;

import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.linker.ConfigurationProperty;
import com.google.gwt.i18n.linker.LocalePropertyProviderGenerator;

public class RestrictedLocalePropertyProviderGenerator extends 
LocalePropertyProviderGenerator {

    @Override
    public String generate(TreeLogger logger, SortedSet<String>possibleValues
, String fallback,
            SortedSet<ConfigurationProperty> configProperties) throws 
UnableToCompleteException {
        
        String original = super.generate(logger, possibleValues, 
fallback,configProperties
);

        // original is now "{ ... code returning locale }", so
        // wrap that into a function, invoke it, and filter the result.
        return "{" +
            "var allowedLocales = {'en':1, 'fr':1 };" +
            "var locale = function() " + original + "();" +
            "while (locale && !(locale in allowedLocales)) {" +
            "  var lastIndex = locale.lastIndexOf('_');" +
            "  if (lastIndex < 0) {" +
            "    locale = null;" +
            "    break;" +
            "  }" +
            "  locale = locale.substring(0, lastIndex);" +
            "}" +
            "return locale || '" + fallback + "'" + 
        "}";
    }
}


Not pretty, but avoids most of the mentioned issues at the cost of 
duplicating my list of allowed values (which change very rarely), and 
ignoring a warning from the GWT compiler to not include gwt-dev as 
dependency.

Regards,
--
Andreas

On Wednesday, March 26, 2014 1:13:51 PM UTC+1, Jens wrote:
>
> Try in your module:
>
> <set-property name="locale" value="en,fr" />
> <set-property-fallback name="locale" value="en" />
> <set-property name="locale" value="en,fr" />
>
> Yes I really mean duplicating that line. See: 
> https://code.google.com/p/google-web-toolkit/issues/detail?id=5769
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to