By default, the Liferay JS Generator creates an empty configuration for
translation. The translate script instructs the user how to add new supported
locales or configure the credentials when it is run. The translate target reads
the supported locales you have defined in the supportedLocales
key of your
.npmbuildrc
file and checks your *language.properties
files to make sure
they match.
Follow these steps to add a new supported locale and automatically create a language properties file for it with translations:
-
Add the locale to the
supportedLocales
array in your.npmbuildrc
file. -
Run the translate target with the command below:
npm run translate
-
The translate target automatically creates a language properties file for each new supported locale with translations for your language keys. It also warns about locales that are not supported, but have a
*language.properties
file.
Great! Now you know how to use the Liferay JS Generator’s translation features in your app.