如何使用 Liferay language.properties 和 jsp 表达式语言?
How to use Liferay language.properties with jsp expression language?
在 Liferay 中,我想做一个显示带有用户名的问候语的 portlet。
此消息可能使用不同的语言。
如何将参数从 jsp 表达式语言转换为语言 属性 字符串?
我试图在 language.properties
中写这样的东西
portlet.body.line1=Hello ${name},
并在我的 view.jsp
中使用它
<liferay-ui:message key="portlet.body.line1" />
但是没用。
我该怎么做?
你不能这样使用表达语言。你必须知道翻译后的文本包含什么,然后像这样使用 Language.properties:
portlet.body.line1=Hello {0}
像这样jsp
<liferay-ui:message key="portlet.body.line1" arguments="Pierre" />
实际上,您可以在这里使用 EL 并使用 arguments="${name}"
- 试试吧。如果您有更多参数(如“{0},{1}”)
,arguments 属性也可以采用字符串数组
在 Liferay 中,我想做一个显示带有用户名的问候语的 portlet。 此消息可能使用不同的语言。
如何将参数从 jsp 表达式语言转换为语言 属性 字符串?
我试图在 language.properties
中写这样的东西portlet.body.line1=Hello ${name},
并在我的 view.jsp
中使用它<liferay-ui:message key="portlet.body.line1" />
但是没用。
我该怎么做?
你不能这样使用表达语言。你必须知道翻译后的文本包含什么,然后像这样使用 Language.properties:
portlet.body.line1=Hello {0}
像这样jsp
<liferay-ui:message key="portlet.body.line1" arguments="Pierre" />
实际上,您可以在这里使用 EL 并使用 arguments="${name}"
- 试试吧。如果您有更多参数(如“{0},{1}”)