Localization of a GWT application created using UiBinder does not work in layout mode

Does localization of a GWT application built with UiBinder work in host mode? This is not for me. Here is what I did:

1) Added locale properties to the GWT XML module

< inherits name="com.google.gwt.i18n.I18N" / > < extend-property name='locale' values='en'/> < extend-property name='locale' values='ru'/> < set-property-fallback name="locale" value="en"/> 

2) Notified messages in * .ui.xml files with

 < ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" ui:generateFormat="com.google.gwt.i18n.rebind.format.PropertiesFormat" ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator" ui:generateLocales="default" xmlns:g="urn:import:com.google.gwt.user.client.ui"> < g:HTMLPanel> < ui:msg description="Hello Description">Hello!< /ui:msg> < /g:HTMLPanel> < /ui:UiBinder> 

3) Added compiler option GWT -extra

4) Compiled the project. Found files with the suffix .GenMessages.properties in the additional folder.

5) Localized generated messages. I copied each .GenMessages.properties file to the same folder with the corresponding .ui.xml file. Renamed it with my locale in the file name, for example. .GenMessages_en.properties .GenMessages_en.properties

6) Compiled the project.

7) Launched the application and changed the locale variable in the URL to check, for example http://127.0.0.1:8888/TestLocale.html?gwt.codesvr=127.0.0.1:9997&locale=en

It still shows me the default English version of resources.

What am I missing? How can I debug it? There is nothing in the magazines or the output.

I'm on Windows using IntelliJ IDEA and Chrome as a browser.

Thanks!

Update: This did not work because I had an additional < set-property name="locale" value="en"/ > in the config module :( Perhaps these were overriding values ​​from the extend-property tag.

I wrote a step-by-step description of how to make it work here if anyone is interested.

+4
source share
2 answers

By default, GWT creates property files starting with the package name. Did you remove the package from the file name?

One thing that works best for me in my GWT projects is to use LocalizableResource_.properties as file names and save them in the com/google/gwt/i18n/client package. Check out the GWT documentation on Localization with UiBinder

+2
source

The .properties file should not be under the client package. The key is to make sure that wherever you decide to save the properties file, make sure that the package in which it is located is also in your module path. In my projects, I usually put property files in a res package:

 com/project/gwt com/project/gwt/client com/project/gwt/res com/project/gwt/res/strings 

Then the main interface, along with all the separate properties files for each language, goes under the lines. This works great as long as the module.xml file contains the line

 <source path="res" /> 
+1
source

Source: https://habr.com/ru/post/1380373/


All Articles