3

Dear Struts 2 and JSP experts,

I can't figure out how to display on the same page a resource bundle key several time but with different locales.

Resource Bundles:

global_fr.properties

#Global messages
global.label = Texte en Français    

global.properties

#Global messages
global.label = Text in English

Expected result:

<table>
  <tr>
    <td>Texte en Français</td>
    <td>${param.label.fr}</td>
  </tr>
  <tr>
    <td>Text in English</td>
    <td>${param.label.en}</td>
  </tr>
</table>

What is the best way to handle this use case with Struts 2 or JSTL ?

Thanks for your help,

Bertrand

bgillis
  • 261
  • 6
  • 18

1 Answers1

2

You can use S2 <s:i18n> tag for that which allows the <s:text> tag to access messages from any bundle, and not just the bundle associated with the current action.

<s:i18n name="global_fr">
    <s:text name="global.label"/>
</s:i18n>

<s:i18n name="global_en">
    <s:text name="global.label"/>
</s:i18n>
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
  • Thanks a lot for your quick reply ! I didn't know I could use tag to force the name of the bundle; bundle of a specific locale in my case. – bgillis Jul 11 '14 at 11:57