如何在 Liferay 7 中翻译内容
How to Translate things in Liferay 7
我在 Liferay 7 中阅读了关于 how to modify language keys 的文章,但没有关于如何翻译多种语言的提示。我想在我的主题中翻译东西,这在 liferay 6.x 中非常容易,但我不知道如何在 liferay 7 中做到这一点。
编辑:我之前做过的:
- 创建 resourcebundle project with blade
- 编辑Language.properties文件并将其部署到我的liferay 7服务器以测试功能
- 创建一个 Language_de.properties 文件,构建并将其部署到 liferay
您必须在 Class 中设置 property = {"language.id=xx_XX"}
才能定义 一种 语言。如果您只是添加另一个 Language_xx_XX.properties 文件,它将无法正常工作。
我的问题是:如何向我的资源包中添加更多语言?
在修改 Liferay 核心语言键的资源包中,我认为每个包只能修改一个语言环境的翻译。
如果您要覆盖部署到 OSGi 运行时的模块中的密钥(这是大多数密钥所在的位置),您将遵循 this tutorial。在这种情况下,我相信您只需添加要覆盖其键的任何语言文件。
Create properly named language properties files for each locale whose
keys you want to override. These should go in src/content, and are the
resource bundles that are loaded by the resource bundle loader you are
implementing.
"If you just add another Language_xx_XX.properties file, it just won't work."
为什么?如果它不起作用,请确保您已在 portlet.xml 文件中提到此文件:
<resource-bundle>content/Language</resource-bundle>
之后,您可以通过 <liferay-ui:message />
标签在 JSP 中使用语言键。
我在 Liferay 7 中阅读了关于 how to modify language keys 的文章,但没有关于如何翻译多种语言的提示。我想在我的主题中翻译东西,这在 liferay 6.x 中非常容易,但我不知道如何在 liferay 7 中做到这一点。
编辑:我之前做过的:
- 创建 resourcebundle project with blade
- 编辑Language.properties文件并将其部署到我的liferay 7服务器以测试功能
- 创建一个 Language_de.properties 文件,构建并将其部署到 liferay
您必须在 Class 中设置 property = {"language.id=xx_XX"}
才能定义 一种 语言。如果您只是添加另一个 Language_xx_XX.properties 文件,它将无法正常工作。
我的问题是:如何向我的资源包中添加更多语言?
在修改 Liferay 核心语言键的资源包中,我认为每个包只能修改一个语言环境的翻译。
如果您要覆盖部署到 OSGi 运行时的模块中的密钥(这是大多数密钥所在的位置),您将遵循 this tutorial。在这种情况下,我相信您只需添加要覆盖其键的任何语言文件。
Create properly named language properties files for each locale whose keys you want to override. These should go in src/content, and are the resource bundles that are loaded by the resource bundle loader you are implementing.
"If you just add another Language_xx_XX.properties file, it just won't work."
为什么?如果它不起作用,请确保您已在 portlet.xml 文件中提到此文件:
<resource-bundle>content/Language</resource-bundle>
之后,您可以通过 <liferay-ui:message />
标签在 JSP 中使用语言键。