Language.properties file in Liferay

匿名 (未验证) 提交于 2019-12-03 01:45:01

问题:

I want to support multiple languages for my portlet application. So I:

  1. Created content package in src folder.
  2. Created Language.properties file with string Book-Name=Book Name
  3. Paste this line

     <supported-locale>es</supported-locale>   <resource-bundle>content/Language</resource-bundle> 

    in portlet.xml file.


So could you please tell me why I still have Book-Name here?!

<liferay-ui:search-container> <liferay-ui:search-container-results results="${bookListArray}" />         <liferay-ui:search-container-row className="com.softwerke.model.Book" modelVar="aBook">         <liferay-ui:search-container-column-text property="bookName" name="Book-Name"/>         <liferay-ui:search-container-column-text property="bookDescription" name="Description"/>         <liferay-ui:search-container-column-jsp path="/html/action.jsp" align="right" />      </liferay-ui:search-container-row>      <liferay-ui:search-iterator /> </liferay-ui:search-container> 

UPDATE

This:

    <liferay-ui:search-container-column-text property="bookName" name="${bookName}" /> 

....

   <c:set var="bookName"> <liferay-ui:message key="book-Name" /> </c:set>  

does NOT work too

回答1:

You are not using it at all. The name="Book-Name" in this line

<liferay-ui:search-container-column-text property="bookName" name="Book-Name"/> 

adds name property to this html component with valye defined inside the quotation marks to make this value the one defined in the properties file you have to use <liferay-ui:message /> tag in your case it would be: :

<liferay-ui:search-container-column-text property="bookName" name="<liferay-ui:message key="Book-Name" />"/> 

Also it is not relevant but a dev practice that the language key is all lower case.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!