Localization¶
Add Localization Item¶
Open the Localization tab at the bottom of the editor. It lists the resources of the business object on the left, and the values of the selected resource on the right.
To add a resource, click the + button at the bottom of the list and choose New Resource.
The resource is created with a default name, such as ProductBO_RES_CUSTOM_ID. Give it a unique name and then, for each language you have selected for your application, fill in its value.
Pre-Defined Items¶
In some cases, you will see some localization resources that Studio added for you. For example, every value of an enumeration gets a resource named Res_ENUM_, followed by the name of the enumeration and the value, as the first image above shows for ProductStatus. And if you set a message to be displayed whenever a Restricted object is being deleted, the resource for that message appears in the Localization tab of the class's business object.
Such resources cannot be renamed. You can, however, set their values, depending on the Languages you have selected for your Application.
If you right-click on such an Item, you will see a pop-up menu with a Locate Item operation. If you click on it, you will be automatically navigated to the exact place where this Localization Item is used (e.g. at the Restricted Message property of an Association)
Usage¶
After defining your Localization Resources, you can use them in your Business Objects' Model Operations and Classes, using the following syntax:
For example, with the resource defined above, an operation can raise a message in the language of the user:
Translatable Attributes¶
The resources above translate the texts of your model: captions, messages, enumeration values. Some texts, though, are part of your data. A product's name or a category's description is typed in by your users, and you may need it in every language of your application.
For such texts, mark the attribute as translatable. Each object then keeps one value of the attribute per language, and every user sees the value of their own language.
Make an Attribute Translatable¶
Select the attribute in the class and check Is Translatable in the Properties Grid. The attribute gets a [T] flag after its definition, next to its other flags. See Attributes.
The property is available only when the attribute:
- is of type
string, - is Persisted, and
- does not belong to an enumeration.
The build also checks that a translatable attribute:
- is not Required, since a language may have no value yet,
- is not Encrypted, and
- belongs to an application built with Use Angular 21, an Experimental option of the Implementation Strategy. Earlier versions of the client do not support translations.
If any of these rules is broken, the build fails with a message that names the attribute and the class.
How the Value Is Read and Written¶
Your code keeps using the attribute as before. With a translatable Name attribute on a Product class:
- Reading
product.Namereturns the value in the language of the current user. If that language has no value, it returns the value of the application's Default Language, which you set in the Localization panel of the Application configuration. - Writing
product.Name = "..."sets the value in the language of the current user only. The values of the other languages are not changed. - Queries that filter or sort on the attribute use the same value: the user's language, or the default language when the user's language has no value. A user searching for products by name searches the names in their own language.
- Length: the attribute's Length applies to the value of every language. Each value that is too long causes a validation error.
- Copying an object also copies all of its translations.
Read and Write a Specific Language¶
For each translatable attribute, the class gets two built-in operations. For an attribute named Name, they are:
| Operation | Description |
|---|---|
string GetNameTranslation(string locale) |
Returns the value of Name in the given language, or null if that language has no value. Unlike reading Name, it does not fall back to the default language. |
void SetNameTranslation(string locale, string translation) |
Sets the value of Name in the given language. |
The locale is the code of one of the application's Available Languages, such as "en" or "el". If no available language has that code, the operation throws an exception.
var product = Domain.Product.Create();
product.SetNameTranslation("en", "Chair");
product.SetNameTranslation("el", "Καρέκλα");
product.Save();
var greekName = product.GetNameTranslation("el");
The operations appear in auto-complete like any other operation of the class. If you have already defined an operation with the same name, Studio shows a warning.
Edit Translations in a Form¶
A Text Box, Text Area or Rich Text Box bound to a translatable attribute shows the language it is editing in its top right corner. The value it shows at first is the one in the user's language.
To edit another language, click the language. A list of the available languages appears: the user's language is underlined and the language being edited is in bold. Pick a language, type its value, and save the form as usual. The values of all the languages you edited are saved together.
Database¶
The values of the translatable attributes of a class are stored in a separate table, named after the class's table followed by $Translations (for example, Product$Translations). The table has one row per object and language, with:
$ProductId: the object the row belongs to,$LanguageId: the language of the row, and- one column for each translatable attribute of the class.
The attribute's own column, in the class's table, is no longer used while the attribute is translatable.
Existing Data¶
You can make an attribute translatable after your application already has data. When the application starts after such a change, it moves the existing data on its own:
- When an attribute becomes translatable, the value of its column is copied to the Default Language of each object, and the column is cleared.
- When an attribute stops being translatable, the value of the default language is copied back to the column, wherever the column is empty. The translations are kept, in case you make the attribute translatable again.
The application remembers which attributes were translatable in the $TranslatableProperties table. If the move fails, for example because no default language is configured, the error is logged and the move is retried on the next start.



