You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexandros Karypidis <ak...@yahoo.gr> on 2010/04/13 18:33:03 UTC
Beginner localization question
Hi,
How can I have Wicket resolve a key to some localized messages with my
own code at runtime? The reason I ask is because I have this use case:
1) I use Java enumerations to strongly-type a RadioChoice control:
public enum RadioOptions { ONE, TWO, THREE }
2) I strongly-type a RadioChoice control:
public SomePage() {
...
RadioOptions radio = RadioOptions.ONE;
RadioChoice<RadioOptions> r = new RadioChoice<RadioOptions>(...,
Arrays.asList(RadioOptions.values()));
...
3) Define localized messages in the MyWicketApplication_xx.xml file:
<entry key="ONE">First option text</entry>
4) Overload toString() as follows:
public enum RadioOptions {
ONE, TWO, THREE;
public String toString() {
String key = this.name(); // "ONE", "TWO" or "THREE"
return .................; // how do I ask Wicket to search for
the localized message?
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Beginner localization question
Posted by Igor Vaynberg <ig...@gmail.com>.
if you have a component/page you can use component.getstring() if not
you can get the localizer from application and use that, afaik
application.get().getresourcesettings().getlocalizer()
-igor
On Tue, Apr 13, 2010 at 9:33 AM, Alexandros Karypidis <ak...@yahoo.gr> wrote:
> Hi,
>
> How can I have Wicket resolve a key to some localized messages with my own
> code at runtime? The reason I ask is because I have this use case:
>
> 1) I use Java enumerations to strongly-type a RadioChoice control:
> public enum RadioOptions { ONE, TWO, THREE }
>
> 2) I strongly-type a RadioChoice control:
> public SomePage() {
> ...
> RadioOptions radio = RadioOptions.ONE;
> RadioChoice<RadioOptions> r = new RadioChoice<RadioOptions>(...,
> Arrays.asList(RadioOptions.values()));
> ...
>
> 3) Define localized messages in the MyWicketApplication_xx.xml file:
> <entry key="ONE">First option text</entry>
>
> 4) Overload toString() as follows:
> public enum RadioOptions {
> ONE, TWO, THREE;
> public String toString() {
> String key = this.name(); // "ONE", "TWO" or "THREE"
> return .................; // how do I ask Wicket to search for the
> localized message?
> }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org