use ui:text from

1,921 views
Skip to first unread message

Luke

unread,
Aug 10, 2011, 11:08:30 AM8/10/11
to Google Web Toolkit
i have html that look like <span title="abc"> </span>

how to i18n the title by using <ui:text from="" ../> inside the
"span"-title element?

Alex Dobjanschi

unread,
Aug 10, 2011, 12:09:04 PM8/10/11
to google-we...@googlegroups.com
read docs?

dindeman

unread,
Aug 10, 2011, 10:59:20 PM8/10/11
to google-we...@googlegroups.com
HTML Attributes that Need Translation
Is that what you're looking for ?

Note that I think 'ui:name' and 'ui:description' are decprecated and should simply be 'name' and 'description'.

Tomasz Gawel

unread,
Aug 11, 2011, 8:10:38 PM8/11/11
to Google Web Toolkit
not exactly,

ui:name and ui:description
are for messages that uibinder generates from templates (e.g.: the
default set messages - the other you should provide anyway as files).
the proper how-to is in the link to docs you gave above.

ui:text is used when you have messages in resources that you expose to
uibinder template. (which is for example what i prefer to do)
than you us eit like this:

<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:with field='msg'
type='com.tomaszgawel.client.YourWidget.Messages'/>
<g:HTMLPanel>
<span>
<ui:text from="{msg.hello}"/>
</span>s
<g:InlineLabel text="{msg.world}" />
</g:HTMLPanel>
</ui:UiBinder>


in java you have sth like that:
public class YourWidget extends Composite {
//messages interface does not need to extend any of
com.google.gwt.i18n.client.* iterfaces but it probably will ;)

interface Messages extends ConstantsWithLookup {
String world();
String hello();
}

@UiField Messages msg; //messages must be ui:field - if you allready
have an instance of messages use @UiField(provided = true)

that's all :)

Tomasz Gawel

unread,
Aug 11, 2011, 8:17:05 PM8/11/11
to Google Web Toolkit
but to the original question ;)

you don,t need <ui:text> markup at all :).
ui:text element has been introduced because you could not use
{messages.messageKey} in plain text not as attribute. as title is an
attribute it is not needed in that case.

just write:

<span title="{msg.yourTitleMessage}"><ui:text from="{msg.someText}" /
></span>

Reply all
Reply to author
Forward
0 new messages