Skip to the content
Documentation

Translatable class attributes

No ratings yet

The name and description of a class and the names of its attributes can be translated into every content language. Editors then see the field labels of the edit form in the language they edit, for example "Car" and "Top speed" in English, "Bil" and "Topphastighet" in Norwegian. Translating a class changes only these texts; its attributes, identifiers and objects stay as they are.

Like an object, a class has a main language: the language it was created in. Its translations are recorded in ezcontentclass.language_mask (see The bit-field algorithm).

Creating a class in a language

  1. Go to Setup > Classes and open the class group.
  2. Choose the language in Language of the new class and press New class. Only content languages of Setup > Languages are offered.
  3. The class edit form shows the language it is edited in. Fill in name, identifier, object name pattern and the other fields, add the attributes, and store the class.

Translating a class

  1. Open the class under Setup > Classes.
  2. In the language list next to Edit, choose Another language and press Edit.
  3. On Edit <class name>, "Select the language you want to add" and, under "Select the language the added translation will be based on", the language to copy the texts from (or None). Press Edit.
  4. Enter the class name, description and attribute names in the new language and store the class.

Editing a translation of a class

Open the class, choose the language in the list next to Edit and press Edit. The class view also has a Translations window that lists the class's languages with an edit link per language.

Main language and removing translations

In the class's Translations window, select another language in the Main column and press Set main to change the main language. Select translations and press Remove selected to remove them; the main language cannot be removed.

A content language cannot be removed while a class has a name in it, including a class edit that was started and never stored. Setup > Languages lists such classes on the language's page; open them, and store or cancel the edit.

In templates and code

The name of a class or attribute is shown in the current language, with the class's main language as fallback: $class.name and $attribute.name in templates, eZContentClass::name() and eZContentClassAttribute::name() in PHP, which take an optional locale.

More

Contributors

Comments (1 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. selection options can't be translated

    4dro ·

    When translating class attributes: the options of 'selection' aren't translatable. It's not a bug, it's just a feature that's not implemented (yet?).
    Is there some overview which attributes are translatable and which aren't?

Comments

Add a comment

Comments are read by a moderator before they appear.