Tips & Tricks - Multilingual data records
If you would like to show data records in more than one language in the portal, e.g. German and English, you need the translation of the data record in each language and the two-letter language code according to ISO 639-1 - e.g. "de" for German and "en" for English. The method described below can of course be used for any number of languages.
Create application
Create a new application based on the application template “Basic application”.
Select the data group in the application structure and create a new data field via the New menu / Data field. Enter "Language code" as the title and select "Short text" as the data type. Click on "OK".
Select the "Entry" input page in the application structure. On the workspace, select the container containing the title field in the grid and then switch to the zoom view by clicking on "Zoom".
Create a selection list here and give it the title "Language". Click "Next".
Select the "Special value sources" option and the "LanguageListProcessor" class. Click "Next".
Select the "Language code" field here and click "Next" and then "Finish".
Now switch to the "All entries" page and open the properties dialog of the view table and add the data field "Language code" as a table column. Click on "OK" and publish the application. Then switch to the browser.
Create a German and English data record on the edit page.
The view table on the "All records" page now shows both records with the language code.
The "LanguageListProcessor" class therefore has the function of displaying the language names in the selection list. It is much easier to select a language than to select the right language code, as these are easily confused. The "LanguageListProcessor" class stores the corresponding language code in the data field. The language-dependent display of data records can only be achieved with the saved language code.
With the help of the "control.listbox.language.usePortalSettings" setting, only the languages that are activated in the portal can be listed. Click here for more information.
To filter the data records dependent on the language, please reopen the properties dialog of the view table.
Create a filter that compares the data field "Language code" with the system value "Language". Publish the application.
Refresh the application in the browser (F5 key). If your portal is set to English, only the English data record will be shown in the table. Now switch the portal to “German”.
The table now shows the German data record only. In addition to the "LanguageListProcessor" class, which provides the entries for the language selection list, there are many other classes which, for example, only list the languages that you have set in the country settings of the portal properties. Click here for more information.
The “dynamic view” element can also be set up to display already saved language codes, like the drop-down list, and then provides the language names instead of the codes.