Zum Hauptinhalt springen
Version: 4.x

adding-custom-fields-multilingual-sites

Multilingual Sites

Articles in this Series

  1. Introduction
  2. Parameters for all Custom Fields
  3. Calendar Field
  4. Checkboxes Field
  5. Color Field
  6. Editor Field
  7. Integer Field
  8. List Field
  9. List of Images Field
  10. Media Field
  11. Radio Field
  12. Repeatable Field
  13. Sql Field
  14. Text Field
  15. Textarea Field
  16. Url Field
  17. User Field
  18. Usergroup Field
  19. How can you group custom fields
  20. What components are supporting custom fields
  21. Implementation into your component
  22. Use custom fields in your overrides

Custom Fields in Multilanguage 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:

  1. Define the Title and Description of your custom field group as language constants
  2. Define the Label and Description of your custom field as language constants
  3. 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).

Multilanguage-custom-field-goup-en.jpg

Defining the Custom Field

Then define a new custom field and assign it to the above field group:

Multilanguage-custom-field-en.jpg

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.

Multilanguage-custom-field-edit-en.jpg

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.

Multilanguage-custom-field-override-en.jpg

After you have entered overrides for the 4 English language constants you should end up with:

Multilanguage-custom-field-overrides-gb-en.jpg

Now select German Administrator and add German translations for each, ending up with:

Multilanguage-custom-field-overrides-de-en.jpg

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:

Multilanguage-custom-field-edit-gb-en.jpgMultilanguage-custom-field-edit-de-en.jpg

Display a Contact

If you display a contact on the front-end then the custom fields are displayed with the language-specific label.

Multilanguage-custom-field-site-gb-en.jpgMultilanguage-custom-field-site-de-en.jpgPrev: Usergroup Field Next: Components supporting custom fields