问题
I want to support multiple languages for my portlet application. So I:
- Created
content
package insrc
folder. - Created
Language.properties
file with stringBook-Name=Book Name
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.
来源:https://stackoverflow.com/questions/39366942/language-properties-file-in-liferay