java - GWT: Using i18n in UiBinder and dynamically -
i want ask question related i18n in gwt.
i have web application uses uibinding, followed online instructions , made uibinder i18n. property generated gwt compiler put directory of:
src/main/java/com/google/gwt/i18n/client/localizableresource_en.properties src/main/java/com/google/gwt/i18n/client/localizableresource_de.properties src/main/java/com/google/gwt/i18n/client/localizableresource_es.properties
i can therefore in web app switch language specifying "&locale=de" in query string of url.
here problem. have other string cannot fit uibinder. decided @ runtime , therefore needs read dynamically. example, given file, need workout file type , display file type in proper language , display like:
mytextfile.txt -> "text"
the word "text" needs change depends on language. because file server , file, cannot statically bind "text" translation key.
question 1: how can in uibinder?
i understand can without using uibinder. can use class extends constants , create getter method read i18n property files. however, question in property files above, string key md5 string. generated gwt compiler. properties not in uibinder, there no equivalent md5 it. how can place them in property file?
will property file this:
952d2c56d0485958336747bcdd98590d=hello apology=sorry
the first property used in uibinder , second 1 used dynamically.
question 2: there chance can avoid hybrid way of mixing properties? either uses separate property files or else.
question 3 : question that: property file named above. because online material says gwt automatically pick property file in:
com/google/gwt/i18n/client/
and filename
localizableresource_xxxx.properties
is possible me put property file in maven's standard resource directory , tells gwt find there?
many thanks.
for question 1:
i don't understand question. if know different file types , translations, put them in localized .properties isn't ?
for instance have
txt=texte
in
localizableresource_fr.properties
then when change locale have use
constants myconstants = gwt.create(myconstants.class); string filetypeproperlytranslated = myconstants.txt();
you check "dictionary", , constantwithlookup suggested in comments.
for question 3:
you have add package gwt.xml. assuming put .properties in com.company.myproject.client package should have in gwt.xml
<entry-point class="com.company.myproject.client.myentrypoint" /> <source path="client" />
then put .properties in maven-compliant src/main/resources/com/company/myproject/client/
you can configure gwt maven plugin... looks in pom.xml:
<plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>gwt-maven-plugin</artifactid> <version>${gwt-maven-plugin.version}</version> <executions> <execution> <goals> <goal>i18n</goal> <goal>...</goal> ... </goals> </execution> </executions>
assuming properties files name messages_en.properties, messages_es.properties, etc., in "configuration" part add following options. (for more options see gwt-maven-plugin doc)
<configuration> <module>${gwt.module}</module> <hostedwebapp>${webappdirectory}</hostedwebapp> <i18nmessagesbundle>com.company.myproject.client.messages</i18nmessagesbundle> <i18nconstantswithlookupbundle>com.company.myproject.client.dynamicmessages</i18nconstantswithlookupbundle> </configuration> </plugin>
i added i18nconstantswithlookupbundle, assuming had dynamicmessages_en.properties, dynamicmessages_es.properties if constantswithlookup satisfy needs question 1.
Comments
Post a Comment