Start page
Start page

Start page / Template development / Rules / Form properties <PROPERTY/> / Property LANG

LANG property and MASTER property

Language-dependent validation

Checkbox “translated”

Editorial contents can be maintained language-dependently. Depending on the languages created for the project by the project administrator, different form elements are available to the editors, such as for inputting text and media, on several language tabs.

The project language in which a form is edited can be checked using a rule. For instance, a rule can be defined using the LANG attribute that enables editing an input component depending on the editing language in which the form is opened.

The expression <PROPERTY source='#global' name='LANG'/> can be used in the value determination of the usual definition (or for the definition of a precondition) and checks in which project language a form was opened. Since this is a generally applicable form property, the object #global has to be assigned to the source attribute. The expression returns the language setting (language code) which is currently being edited within the form.

In order to define a complete condition for language-dependent validation, a comparison value and an operator must be specified. Thus there are conditions such as these:

  • “Was the form opened in the project language EN?” or
  • “Was the form opened in the project master language?”

A comparison value such as these is required:

  • A constant textual comparison value (e.g. <TEXT>EN</TEXT>) or
  • A variable comparison value, such as the master language of the project (<PROPERTY source='#global' name='MASTER'/> )

And an <EQUAL/> operator has to be specified. In this case, the expression returns a Boolean value.

Important Rules in dynamic forms have an effect on all project languages (as long as not defined otherwise). Thus, if the template developer specifies that a specific input field in a form has to be filled before the form can be saved, then the editor has to fill in the affected input field, in all project languages, when creating or editing a form based on this rule in order to be able to save the form. This behavior can be avoided using a language-dependent precondition/validation.

Examples

Example 1) Define precondition for language-dependent validation

The definition of a precondition is ideally suited for language-dependent validation. In the following example, the rule will go through depending on a specific editing language.

The expression <PROPERTY source="#global" name="LANG"/> is used within a precondition for this purpose. The <PROPERTY/> tag returns the corresponding language information, such as “EN”. If this language information is identical to the comparison value, the precondition is considered met.

Precondition for a specific project language: A textual constant is used as a comparison value here and an equivalence check (< EQUAL/>) is carried out. The precondition is met if the form is opened in the editing language “DE”.

...
<IF>
<EQUAL>
<PROPERTY source="#global" name="LANG"/>
<TEXT>DE</TEXT>
</EQUAL>
</IF>
...

Precondition for the project-master language: The project-master language is retrieved as a comparison value here via an additional PROPERTY/> tag and an equivalence check (<EQUAL/>) is carried out. The precondition is met if the form is opened in the project master language.

...
<IF>
<EQUAL>
<PROPERTY source="#global" name="LANG"/>
<PROPERTY source="#global" name="MASTER"/>
</EQUAL>
</IF>
...

Also see the example: Language-dependent validation using a precondition.

Example 2) Displaying form contents depending on the project language

The following form contains a design element of type CMS_GROUP (“st_german”). A dynamic form is used to ensure that this form content is shown to the editor only in the project language “DE” .

To do so, the expression <PROPERTY source="#global" name="LANG"/> is used within the value determination. The <PROPERTY/> tag returns the corresponding language information. This is checked against a constant comparison value. The result of this check is a Boolean value, which is then linked to a handling instruction in the <DO/> section. If the condition is met (value determination returns TRUE), the form content “st_german” becomes “visible” via an additional <PROPERTY/> tag.

...
<ON_EVENT>
<WITH>
<EQUAL>
<!-- global property: LANG -->
<PROPERTY source="#global" name="LANG"/>
<!-- /global property: LANG -->
<TEXT>DE</TEXT>
</EQUAL>
</WITH>
<DO>
<PROPERTY source="#form.st_german" name="VISIBLE"/>
</DO>
</ON_EVENT>
...

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2013-12-09