0
votes

I'd like to use dynamic internationalization in my GWT app, with a Dictionary class approach.

Can I use it with uiBinder like this?

<g:HTMLPanel>
    <span>{Dictionary.getDictionary("locale").get("hello_world_key")}</span>
</g:HTMLPanel>

(Flex mxml files work like this.)

1

1 Answers

1
votes

No, UiBinder only supports calling zero-arg non-static methods or importing static fields.

You'd have to hide the dictionary behind a class or interface to be able to do something like {myDictionary.hello_world_key}.

IMO, if you do want to use dynamic I18N, use an interface similar to com.google.gwt.i18N.shared.Constants and make your own generator so that String hello_world_key(); maps to get("hello_world_key") on a Dictionary instance. Your code will read better and become more maintainable.