Generating Translations Automatically
Liferay includes translations for more than 45 languages. When you build an application with custom language keys, translating them into all those languages by hand is tedious. Liferay’s Language Builder tool generates the translations for you, using Microsoft’s Translator API.
The accuracy and correctness of machine translation can vary from language to language. Use them at your own risk.
See the Sample Project
Start a new Liferay DXP instance by running
docker run -it -m 8g -p 8080:8080 liferay/dxp:2026.q1.9-lts
Sign in to Liferay at http://localhost:8080 using the email address test@liferay.com and the password test. When prompted, change the password to learn.
Then, follow these steps:
-
Download and unzip Automatically Generating Translations.
curl https://resources.learn.liferay.com/examples/liferay-m7d6.zip -Ounzip liferay-m7d6.zip -
Open the
gradle.propertiesfile in the module root folder. Add your Microsoft Translator subscription key:microsoft.translator.subscription.key=[your unique key]Note for Language Builder to work, you must obtain your own Microsoft Translator subscription key.
-
From the module root, run Language Builder.
./gradlew buildLangIn your terminal window, Language Builder generates the different language properties files. Note, if you see the error
Translation is disabled because credentials are not specified, double-check that your subscription key is correct. -
Navigate to the module’s
src/main/resources/contentfolder to view the translated properties files.

Adding Your Language Keys
The sample project has one language key in the Language.properties file. Add as many language keys as you need for your application, then run Language Builder.
To deploy the language keys to Liferay, see Overriding Global Language Translations with Language Properties. The instructions are the same whether overriding existing keys or adding new keys.
If you want to exclude some languages from being translated automatically, use the excludedLanguageIds property in your project’s build.gradle file. For example, to exclude French,
buildLang {
excludedLanguageIds = ["fr"]
}
To learn more about the Language Builder tool and additional configuration, see Lang Builder Gradle Plugin.