Joomla 4/5 User Manual
Adding custom fields/Multilingual Sites
If you have a multilingual site then you can display the labels and descriptions of custom fields and field groups in the user's language. To do this:
- Define the Title and Description of your custom field group as language constants
- Define the Label and Description of your custom field as language constants
- Set up those language constants as overrides for each of your languages
In the following example we set up a Contact custom field group and custom field. We define a custom field group relating to the contact's personal preferences called Favourites. And inside the Favourites field group we add a custom field for Car.
We define the above attributes as language constants, and then define text for these language constants in English and German. The result is that the custom field group and custom field are shown in both the administrator and site areas in the user's language.
(To use these features it's assumed you have your site set up to be multilingual, as described in the Setup a Multilingual Site tutorial.)
Defining the Custom Field Group¶
Within the Contacts areas define a new custom field group as shown below. (Note that it's best to choose a language constant that doesn't start with one of the Joomla components etc, to avoid possible future clashes with newer versions of Joomla).
Defining the Custom Field¶
Then define a new custom field and assign it to the above field group:
Edit a Contact (before strings translated)¶
When you now edit a contact record you should see the new custom field within a tab for the Favourites. At this stage the language constant strings we entered will be displayed.
Defining the Overrides¶
Now go into Extensions / Languages / Overrides. Select the English Administrator in the drop-down box, and create overrides for each of the language constants. Select For Both Locations so that the language constant is used on the front-end as well.
After you have entered overrides for the 4 English language constants you should end up with:
Now select German Administrator and add German translations for each, ending up with:
Edit a Contact¶
Now when a Contact is edited in the back-end the custom field and field group are displayed in the administrator's language:
Display a Contact¶
If you display a contact on the front-end then the custom fields are displayed with the language-specific label.