简体   繁体   中英

How to localize a Wicket message in Java code?

I follow this example: https://cwiki.apache.org/WICKET/everything-about-wicket-internationalization.html but I didnt found how to create localization message in java code.

My situation is:

try {

...

} catch (RuntimeException e) {
  // depends on language log message and show it in feedbackPanel
  error("");
}

I know I can add there some switch because I can get current locale but I dont think this is clear solution. I want to solve it througt Page.lanugage.properties where I have all localization messages

Wicket provides a getString() on Component that does proper localisation.

In your example:

try {

 ...

} catch (RuntimeException e) {
    // depends on language log message and show it in feedbackPanel
    error(getString("some.property.id"));
}

Where some.property.id gets loaded via Wickets property loader from a property file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM