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:

    1. use url query parameter control current locale
    2. without specifying additional property file
    3. 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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -