How can I internationalize a GWT UIBinder page with Messages?

前端 未结 3 626
南方客
南方客 2020-12-28 16:33

I am trying to internationalize a UIBinder application with property files. Since we have already a lot of translations exposed by the com.google.gwt.i18n.client.Messages in

3条回答
  •  感动是毒
    2020-12-28 17:00

    Update:
    please check logan's answer below for a solution available in recent versions of GWT.


    I had (actually, have) the same problem as you do - after migrating to GWT 2.0 I had a properties file I wanted to use in my UiBinder files. Unfortunately, I couldn't get it to work like I wanted to - it seems the GWT devs want people to use the syntax described in the i18n guide for UiBinder - where a Message interface is created during compile for every UiBinder template, etc.

    Anyway, you can still use external Messages interfaces like this:

    
    
        
        
        
            .required {
          color: red;
          font-weight: bold;
        }
        .right {
          text-align: right;    
        }
        .textBox {
          margin-right: 7px;
        }
        
        
            

    Though, that only works for stuff like Button's title, etc, not content of divs :/ You can fill those in the class behind the UiBinder template, but there should be a better way.

    I was hoping that you could set the inner HTML via innerHTML (since UiBinder should recognize that method and allow to set it's value via XML/UiBinder template) but alas, last time I checked it didn't work :/

提交回复
热议问题