A standard property stores a single unit of data; a multi-language property stores one unit of data per data language defined in the model.
Usage
Call ClassBuilder.Add.MultiLanguageProperty(...)
on a ClassBuilder
in a metadata builder to add a multi-language property to that class.
Elements.Person.Add.MultiLanguageProperty("Notes");
The default type of the property is MetaType.Text
, but you can make multi-language properties for any type.
Elements.Person.Add.MultiLanguageProperty("Attachment", MetaType.Binary);
Structure
Adding a multi-language property includes the following properties in the class:
A calculated property with the original name (e.g. "Notes" above) that returns the value of the language-specific property for the current language
A property for each data language in the model
The multi-language property itself has a list of Properties
that contains the language-specific properties.
Naming
The name of the multi-language property is taken from the parameter passed to the builder method. The names of the language-specific properties are generated using IMetaNameTools.GetName()
(for which an application can register its own service). By default, the service appends the name of the language (e.g. "Notes_en").
Storage
The ORM and schema-migration both support multi-language properties. A multi-language property maps to n columns in the database table of its meta-class, one for each data language.
Code-Generation
The generated metadata and generated classes both support multi-language properties.
The metadata includes references to IMetaMultiLanguageProperty
objects instead of single-language IMetaProperty
objects.
In addition to the getter for the calculated property (e.g. Notes
), the generated class includes two methods to provide statically typed access to the language-specific values (e.g. GetNotes(ILanguage language)
and SetNotes(ILanguage, string)
).
Layouts
Call the LinkMultiLanguage(...)
on a LayoutBuilder
to add the property to the given layout. Per default this will add:
The calculated property if used on a list layout.
The actual language properties if used in a detail layout.
As an alternative a developer can always include a property explicitly by calling Link(...)
instead of LinkMultiLanguage(...)
.