Language Client Extensions
Liferay DXP 2025.Q1+/Portal GA132+
A language client extension adds new language keys or overrides existing keys and their translations. For example, you can translate frontend token labels in a theme CSS client extension, providing a better user experience. The Language Override tool can accomplish the same thing, but keeping the translations with the client extensions that provide the keys enhances their portability.
To add or override language keys in a client extension, provide a Language.properties
file with keys and values in the workspace’s language
folder. Generate automatic translations by running ../gradlew buildLang
and deploy with ../gradlew clean deploy
from the language
folder. Under the hood the language client extension is a batch client extension that relies on the /o/language/v1.0/
headless endpoint.
To try out the language client extension from the sample workspace,
-
Download and unzip a sample workspace.
curl -o com.liferay.sample.workspace-latest.zip https://repository.liferay.com/nexus/service/local/artifact/maven/content\?r\=liferay-public-releases\&g\=com.liferay.workspace\&a\=com.liferay.sample.workspace\&\v\=LATEST\&p\=zip
unzip com.liferay.sample.workspace-latest.zip
-
From the
language
folder, update theLanguage.properties
file with the keys you want to add or override, then run../gradlew buildLang
-
Deploy the client extension by running
../gradlew clean deploy -Ddeploy.docker.container.id=$(docker ps -lq)
Only translations for languages enabled in the instance are imported. If there are additional languages in the client extension, they are not imported and an error like this one appears in the log:
com.liferay.portal.language.override.exception.PLOEntryLanguageIdException$MustBeAvailable: Language ID "pt_PT" is not one of the available language IDs: [en_US, ar_SA, ca_ES, zh_CN, nl_NL, fi_FI, fr_FR, de_DE, hu_HU, ja_JP, pt_BR, es_ES, sv_SE]
at com.liferay.portal.language.override.service.impl.PLOEntryLocalServiceImpl._validate(PLOEntryLocalServiceImpl.java:238) ~[?:?]
...