Skip to content

Commit fd5c840

Browse files
committed
Documentation on the localization feature for UI Builder
1 parent 6fb03f0 commit fd5c840

File tree

10 files changed

+136
-0
lines changed

10 files changed

+136
-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: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
description: Using the available context to handle localization for an UI Builder collection
3+
---
4+
5+
# Localization
6+
7+
The localization context available in UI Builder enables developers to use multilingual collection names and descriptions with their fluent configuration, as well as translations for actions, context apps, dashboards, sections or trees.
8+
9+
To enable localization the input string must be prefixed by 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+
To provide localization options, the context is using two abstractions.
16+
17+
One is using the Umbraco translations dictionary to retrieve a value based on a provided key.
18+
19+
The other uses the CMS `ILocalizedTextService` to retrieve a value based on area and alias (these will be supplied in the collection's fluent configuration separated by `_`) from the localization resources.
20+
21+
## Example
22+
23+
For a `Students` collection we would use the following fluent configuration:
24+
25+
```csharp
26+
treeConfig.AddCollection<Student>(x => x.Id, "#CollectionStudents", "#CollectionStudents", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
27+
{
28+
...
29+
});
30+
```
31+
32+
![collection_translation](../images/collection_translation.png)
33+
34+
Or
35+
36+
```csharp
37+
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
38+
{
39+
...
40+
});
41+
```
42+
43+
```
44+
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api";
45+
46+
export default {
47+
collection: {
48+
students: "Studerende"
49+
}
50+
...
51+
}
52+
```
53+
54+
![collection_name](../images/collection_name.png)
55+
56+
For a custom section we can use the following configuration:
57+
58+
```csharp
59+
.AddSection("#UmbracoTraining", sectionConfig =>
60+
{
61+
...
62+
}
63+
```
64+
65+
![section_name](../images/section_name.png)
66+
67+
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: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
description: Using the available context to handle localization for an UI Builder collection
3+
---
4+
5+
# Localization
6+
7+
The localization context available in UI Builder enables developers to use multilingual collection names and descriptions with their fluent configuration, as well as translations for actions, context apps, dashboards, sections or trees.
8+
9+
To enable localization the input string must be prefixed by 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+
To provide localization options, the context is using two abstractions.
16+
17+
One is using the Umbraco translations dictionary to retrieve a value based on a provided key.
18+
19+
The other uses the CMS `ILocalizedTextService` to retrieve a value based on area and alias (these will be supplied in the collection's fluent configuration separated by `_`) from the localization resources.
20+
21+
## Example
22+
23+
For a `Students` collection we would use the following fluent configuration:
24+
25+
```csharp
26+
treeConfig.AddCollection<Student>(x => x.Id, "#CollectionStudents", "#CollectionStudents", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
27+
{
28+
...
29+
});
30+
```
31+
32+
![collection_translation](../images/collection_translation.png)
33+
34+
Or
35+
36+
```csharp
37+
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
38+
{
39+
...
40+
});
41+
```
42+
43+
```
44+
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api";
45+
46+
export default {
47+
collection: {
48+
students: "Studerende"
49+
}
50+
...
51+
}
52+
```
53+
54+
![collection_name](../images/collection_name.png)
55+
56+
For a custom section we can use the following configuration:
57+
58+
```csharp
59+
.AddSection("#UmbracoTraining", sectionConfig =>
60+
{
61+
...
62+
}
63+
```
64+
65+
![section_name](../images/section_name.png)
66+
67+
22.4 KB
Loading
34.7 KB
Loading
50.2 KB
Loading

0 commit comments

Comments
 (0)