views:

128

answers:

2

Hi!

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 key 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?

A: 
 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.

McDowell
I need to include locale name, because all project still is only in English. But question was not about that.
Yurish
@Yurish - it's called `basename` because you shouldn't include the locale suffix :)
Bozho
+3  A: 

Use:

value="#{msg[currentDoc.textToTransl]}"
Bozho
if my textToTransl is in #{currentDoc.textToTransl}, then i can do #{msg[#{currentDoc.textToTransl}]}?
Yurish
no, see my update.
Bozho