Search code examples
strutsstruts-1

does not change the locale with using LocaleAction


i use struts 1.3 and want to make localization. that's what I'm doing:

  1. in struts-config.xml:

    <form-bean name="English" type="org.apache.struts.action.DynaActionForm">
        <form-property name="language" type="String" initial="en" />
    </form-bean>
    <form-bean name="Russian" type="org.apache.struts.action.DynaActionForm">
        <form-property name="language" type="String" initial="ru" />
    </form-bean>
    
    <action-mappings>
        <action path="/English" name="English"
            type="org.apache.struts.actions.LocaleAction">
        <forward name="success" path="/index.jsp" />
    </action>
    <action path="/Russian" name="Russian"
            type="org.apache.struts.actions.LocaleAction">
        <forward name="success" path="/index.jsp" />
    </action>
    

    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
    
  2. on jsp.page

    <html:link action="/Russian">
        <bean:message key="jsp.header.russian"/>
    </html:link>
    <html:link action="/English">
            <bean:message key="jsp.header.english"/>
    </html:link>
    

maybe i do something wrong? any ideas?
P.S. yes, i have messages_ru.properties and messages_en.properties.


Solution

  • Oh, I found the reason, struts do not know of this type as a String.

    <form-property name="language" type="java.lang.String" initial="en" />