Skip to content

Commit 20f53e3

Browse files
authored
Merge pull request #7484 from acoumb/uibuilder/localization
Documentation on the localization feature for UI Builder
2 parents 02c510c + 4baa158 commit 20f53e3

File tree

10 files changed

+144
-0
lines changed

10 files changed

+144
-0
lines changed

15/umbraco-ui-builder/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* [Retrieve Child Collections](collections/retrieve-child-collections.md)
4747
* [Related Collections](collections/related-collections.md)
4848
* [Entity Identifier Converters](collections/entity-identifier-converters.md)
49+
* [Localization](collections/localization.md)
4950

5051
## Searching
5152

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
description: Using the available context to handle localization for an UI Builder collection
3+
---
4+
5+
# Localization
6+
7+
The localization context enables developers to use multilingual collection names and descriptions in fluent configurations. It also supports translations for actions, context apps, dashboards, sections, and trees.
8+
9+
To enable localization, prefix the input string with the `#` character.
10+
11+
Upon character identification in the fluent configuration, the localization context will attempt to lookup a matching localized string using two services available. If no matching record is found, it will default to the provided string value.
12+
13+
## Localization Services
14+
15+
The localization context uses two abstractions to provide localization options.
16+
17+
The first uses the Umbraco translations dictionary to retrieve a value based on a provided key.
18+
19+
The second uses the CMS `ILocalizedTextService` to retrieve a value based on area and alias. These values are supplied in the collection's fluent configuration, separated by an underscore `_` from the localization resources.
20+
21+
## Example
22+
23+
### Localizing a Collection
24+
25+
For a `Students` collection, use the following fluent configuration:
26+
27+
```csharp
28+
treeConfig.AddCollection<Student>(x => x.Id, "#CollectionStudents", "#CollectionStudents", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
29+
{
30+
...
31+
});
32+
```
33+
34+
![collection_translation](../images/collection_translation.png)
35+
36+
Alternatively, you can use the lowercase version:
37+
38+
```csharp
39+
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
40+
{
41+
...
42+
});
43+
```
44+
45+
Define the translation in your localization dictionary file:
46+
```
47+
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api";
48+
49+
export default {
50+
collection: {
51+
students: "Studerende"
52+
}
53+
...
54+
}
55+
```
56+
57+
![collection_name](../images/collection_name.png)
58+
59+
### Localizing a Section
60+
For a custom section, use the following configuration:
61+
62+
```csharp
63+
.AddSection("#UmbracoTraining", sectionConfig =>
64+
{
65+
...
66+
}
67+
```
68+
69+
![section_name](../images/section_name.png)
70+
71+
22.4 KB
Loading
34.7 KB
Loading
50.2 KB
Loading

16/umbraco-ui-builder/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* [Retrieve Child Collections](collections/retrieve-child-collections.md)
4545
* [Related Collections](collections/related-collections.md)
4646
* [Entity Identifier Converters](collections/entity-identifier-converters.md)
47+
* [Localization](collections/localization.md)
4748

4849
## Searching
4950

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
description: Using the available context to handle localization for an UI Builder collection
3+
---
4+
5+
# Localization
6+
7+
The localization context enables developers to use multilingual collection names and descriptions in fluent configurations. It also supports translations for actions, context apps, dashboards, sections, and trees.
8+
9+
To enable localization, prefix the input string with the `#` character.
10+
11+
Upon character identification in the fluent configuration, the localization context will attempt to lookup a matching localized string using two services available. If no matching record is found, it will default to the provided string value.
12+
13+
## Localization Services
14+
15+
The localization context uses two abstractions to provide localization options.
16+
17+
The first uses the Umbraco translations dictionary to retrieve a value based on a provided key.
18+
19+
The second uses the CMS `ILocalizedTextService` to retrieve a value based on area and alias. These values are supplied in the collection's fluent configuration, separated by an underscore `_` from the localization resources.
20+
21+
## Example
22+
23+
### Localizing a Collection
24+
25+
For a `Students` collection, use the following fluent configuration:
26+
27+
```csharp
28+
treeConfig.AddCollection<Student>(x => x.Id, "#CollectionStudents", "#CollectionStudents", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
29+
{
30+
...
31+
});
32+
```
33+
34+
![collection_translation](../images/collection_translation.png)
35+
36+
Alternatively, you can use the lowercase version:
37+
38+
```csharp
39+
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
40+
{
41+
...
42+
});
43+
```
44+
45+
Define the translation in your localization dictionary file:
46+
```
47+
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api";
48+
49+
export default {
50+
collection: {
51+
students: "Studerende"
52+
}
53+
...
54+
}
55+
```
56+
57+
![collection_name](../images/collection_name.png)
58+
59+
### Localizing a Section
60+
For a custom section, use the following configuration:
61+
62+
```csharp
63+
.AddSection("#UmbracoTraining", sectionConfig =>
64+
{
65+
...
66+
}
67+
```
68+
69+
![section_name](../images/section_name.png)
70+
71+
22.4 KB
Loading
34.7 KB
Loading
50.2 KB
Loading

0 commit comments

Comments
 (0)