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.
精彩评论