简体   繁体   中英

How can I use wicket i18n features without a running wicket application

Given:

  • a wicket application with fully configured *.properties files for multiple languages

Required:

  • a batch application should also be able to get a localized value, using key and locale, with locale fallbacks and so on, behaving just like wicket normally does this.

Tried so far:

  • WicketApplication.get().getResourceSettings().getLocalizer() - does not work, as no wicket application is available in the context of batch application.

See org.apache.wicket.resource.loader.ComponentStringResourceLoader#loadStringResource(java.lang.Class, java.lang.String, java.util.Locale, java.lang.String, java.lang.String) [1]. This is where the magic happens.

  1. https://github.com/apache/wicket/blob/792a0a4138aad61dfe63c8bace96648878767003/wicket-core/src/main/java/org/apache/wicket/resource/loader/ComponentStringResourceLoader.java#L131-L151

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