RE: (resolved)Internationalize in Spring plugin portlet

2364382, modified 15 Years ago. Liferay Master Posts: 660 Join Date: 3/3/09 Recent Posts
Hi,

I want to translate the following dash words into "words", like the one in language-ext.properties written for Struts protlet.



  	<b><liferay-ui:message key="login-details" /></b>
  


  <liferay-ui:message key="mpp-username" />
  
	<input name="userName" type="text" size="25" style="width: 200px;" value="${companyDetails.userName}">
  



I have tried to put a language-ext.properties file under WEB-INF/ directory, but there is no translation happening. I am still seeing the dash keywords in webpage.

Thsi is a spring portlet.
Can anyone please tell me how to resove this problem in Spring?

Thanks
Sam
thumbnail
4775869, modified 15 Years ago. New Member Posts: 21 Join Date: 3/30/10 Recent Posts
In your name-portlet.xml spring context you can define something like this :

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="com/project/locale/message" />
</bean>

And in you com/project/locale/ folder you can have a message_fr.properties, message_en.properties, etc.

Another thing, in your jsp : it's not <liferay-ui:message key="mpp-username" /> anymore but

<spring:message code="mpp-username" />
2364382, modified 15 Years ago. Liferay Master Posts: 660 Join Date: 3/3/09 Recent Posts
Julien Deruere:
In your name-portlet.xml spring context you can define something like this :

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="com/project/locale/message" />
</bean>

And in you com/project/locale/ folder you can have a message_fr.properties, message_en.properties, etc.

Another thing, in your jsp : it's not <liferay-ui:message key="mpp-username" /> anymore but

<spring:message code="mpp-username" />


I thought this is very simple, but I am getting the following error:


01:55:33,369 WARN  [ResourceBundleMessageSource:219] ResourceBundle [au.com.xyz.messages] not found for MessageSource: Can't find bundle for base name au.com.xyz.messages, locale en_US
01:55:33,369 ERROR [MessageTag:80] No message found under code 'login-details' for locale 'en_US'.
javax.servlet.jsp.JspTagException: No message found under code 'login-details' for locale 'en_US'.
        at org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:183)
        at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
        at org.apache.jsp.jsp.wizUserProfile_jsp._jspx_meth_spring_005fmessage_005f0(wizUserProfile_jsp.java:654)
        at org.apache.jsp.jsp.wizUserProfile_jsp._jspService(wizUserProfile_jsp.java:437)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)



Thanks
Sam
thumbnail
4775869, modified 15 Years ago. New Member Posts: 21 Join Date: 3/30/10 Recent Posts
Where did you put your message_en_US.properties and can I see your configuration in your name-portlet.xml?
2364382, modified 15 Years ago. Liferay Master Posts: 660 Join Date: 3/3/09 Recent Posts
Julien Deruere:
Where did you put your message_en_US.properties and can I see your configuration in your name-portlet.xml?


I have fixed the error. The problem was because the path.filenameis different to the filename.properties file.

Thank you Julien.

Sam.
2364382, modified 15 Years ago. Liferay Master Posts: 660 Join Date: 3/3/09 Recent Posts
Sam Wan:
Hi,

I want to translate the following dash words into "words", like the one in language-ext.properties written for Struts protlet.



  	<b><liferay-ui:message key="login-details" /></b>
  


  <liferay-ui:message key="mpp-username" />
  
	<input name="userName" type="text" size="25" style="width: 200px;" value="${companyDetails.userName}">
  



I have tried to put a language-ext.properties file under WEB-INF/ directory, but there is no translation happening. I am still seeing the dash keywords in webpage.

Thsi is a spring portlet.
Can anyone please tell me how to resove this problem in Spring?

Thanks
Sam


Thank you very much for the suggestion.
That works well.

Thanks again.
Sam
thumbnail
Aravinth Kumar, modified 5 Years ago. Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
Hi All,I want to use spring message tag instead of liferay ui message tag. I want to read the global keys such as control panel but its throwing  " No message found under code 'control-panel' for locale 'en_US' ". 
<spring:message code="control-panel" />&nbsp;


Do we need to add anything in messagesource in portlet-application-context.xml.
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
&nbsp; <property name="basenames">
&nbsp;&nbsp; <list>
&nbsp;&nbsp;&nbsp; <value>????</value>
&nbsp;&nbsp; </list>
&nbsp; </property>
&nbsp; <property name="defaultEncoding" value="UTF-8" />
</bean>

Thanks in Advance. 

Regards,
Aravinth