开发者

I18n - JSF variable value translation

开发者 https://www.devze.com 2023-01-01 00:25 出处:网络
I am using Bundle Internationalization in my project. I have initialized bundle via <f:loadBundle basename=\"ui.all.bundles.AppResources_en\" var=\"msg\"/>

I am using Bundle Internationalization in my project. I have initialized bundle via

<f:loadBundle basename="ui.all.bundles.AppResources_en" var="msg"/>

When i need to translate some text, i am using a ke开发者_如何学编程y to resourceBundle, to get a value of it, for example: #{msg.someText}. But, now i want to translate text, which key is a value of another variable. For example:

I have variable String textToTransl. It`s value is status_booked. In my AppResources is defined, that status_booked means "It is booked!", so, when i am pointing it to #{msg.textToTransl} i need to see "It is booked!"

How can i make it work?


Use:

value="#{msg[currentDoc.textToTransl]}"


 ui.all.bundles.AppResources

Don't include the locale (_en) in the resource name. The resource bundle code should resolve the locale-specific bundle based on the request locale.

0

精彩评论

暂无评论...
验证码 换一张
取 消