java - GWT: How to avoid specify default property file using i18n Constants -
i making web app using gwt i18n.
i have interface defines
public interface myconstants extends constants { string value(); }
and 3 property files:
myconstants_en.properties myconstants_es.properties myconstants_de.properties
when compile code, gave me error:
[info] processing interface com.mycompany.myproject.client.i18n.myconstants [info] generating method body value() [info] [error] no resource found key 'value'
there 2 ways solve this,
add following line gwt module definition ".gwt.xml" file:
<set-property name="locale" value="en" />
however, if this, lost ability specify locale using query parameter "&locale=de". page stays english.
add additional property file myconstants.properties contains same contents myconstants_en.properties.it works perfectly. however, don't want keep both myconstants.properties , myconstants_en.properties have same contents.
is there way can:
- use url query parameter control current locale
- without specifying additional property file
- successfully build it.
many thanks.
gwt comes out of box configured call "default" locale has basic localization settings. default locale looking myconstants.properties file. if want "default" locale myconstants_en.properties make following adjustments gwt.xml module file.
<!-- inherit these modules activate gwt internationalization --> <inherits name='com.google.gwt.i18n.i18n' /> <inherits name="com.google.gwt.i18n.cldrlocales"/> <!-- add various locales wish support --> <extend-property name="locale" values="en"/> <extend-property name="locale" values="es"/> <extend-property name="locale" values="de"/> <!-- instructs application use locale when there no locale specified (i.e. replaces default) --> <set-property-fallback name="locale" value="en" />
by setting "set-property-fallback" "en" application use myconstants_en.properties file.
hope helps...
Comments
Post a Comment