For a given locale, you can override Liferay’s core UI messages.
Modifying Language key values in Liferay provides a lot of localization
flexibility in itself, but we’re always looking for new ways to give you more
control. There are language settings in Liferay’s
that give you even more localization options.
In the add and edit user forms, configure the name fields that are displayed and the field values available in select fields. For example, leave out the middle name field if you want, or alter the prefix selections.
Control the directionality of content and messages in Liferay (left to right or right to left).
To see how these settings are configured, open Liferay’s core
in one of two ways:
From Liferay’s source code, navigate to
From a Liferay bundle’s
Just open the
contentfolder in the Jar to find the language files.
The first section in the
Language.properties file is labeled Language
## ## Language settings ## lang.dir=ltr lang.line.begin=left lang.line.end=right lang.user.name.field.names=prefix,first-name,middle-name,last-name,suffix lang.user.name.prefix.values=Dr,Mr,Ms,Mrs lang.user.name.required.field.names=last-name lang.user.name.suffix.values=II,III,IV,Jr,Phd,Sr
The user name properties are used to customize certain fields of the add and edit user forms based on a user’s locale.
Localizing User Names
Liferay’s customers come from all over the world, and we recognize that naming conventions are different between locales. Liferay’s engineers have made several of the user name fields configurable in Liferay where user name information is entered or edited.
Remove certain name fields and make others appear more than once. Some locale’s need more than one last name, for example.
Change the prefix and suffix values for a locale.
Specify which fields are required.
The properties for changing user name settings are those that begin with
lang.user.name in the language settings section of a locale’s language
For most of the [locales enabled by default](https://docs.liferay.com/dxp/digital-enterprise/7.0-latest/propertiesdoc/portal.properties.html#Languages and Time Zones) the user name properties are specifically tailored to that location.
For example, these are the English (
Language_en.properties) properties for
setting user name fields:
lang.user.name.field.names=prefix,first-name,middle-name,last-name,suffix lang.user.name.prefix.values=Dr,Mr,Ms,Mrs lang.user.name.required.field.names=last-name lang.user.name.suffix.values=II,III,IV,Jr,Phd,Sr
Compare those to the Spanish (
lang.user.name.field.names=prefix,first-name,last-name lang.user.name.prefix.values=Sr,Sra,Sta,Dr,Dra lang.user.name.required.field.names=last-name
The biggest difference between the English and Spanish form fields in the images above is that the middle name and suffix fields are omitted in the Spanish configuration. Other differences include the specific prefix values.
¡Muy excelente! Localizing the forms for adding and editing users is
accomplished using the same method by which Liferay’s UI messages are localized:
by overriding one of Liferay’s
Right to Left or Left to Right?
The first three properties in the language settings section are used for changing the direction in which the language’s characters are displayed. Most languages are read from left to right, but other languages are meant to be read from right to left (Arabic, Hebrew, and Persian, for example). It can also be changed for languages that have been traditionally displayed left to right (like English) as a funny practical joke. Just don’t tell anyone that you got the idea here.
Here’s what the relevant language properties look like for a language that should be displayed from right to left:
lang.dir=rtl lang.line.begin=right lang.line.end=left
With these customizations yo can transform Liferay’s UI into a user-friendly environment no matter where your users are from.