-
Notifications
You must be signed in to change notification settings - Fork 808
Documentation on the localization feature for UI Builder #7484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
fd5c840
b7fca13
4def609
51291be
61fbe63
1686e0b
70870a7
d154e16
90aa581
8f442cc
4baa158
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
description: Using the available context to handle localization for an UI Builder collection | ||
--- | ||
|
||
# Localization | ||
|
||
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. | ||
Check warning on line 7 in 15/umbraco-ui-builder/collections/localization.md
|
||
|
||
To enable localization the input string must be prefixed by the `#` character. | ||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
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. | ||
|
||
## Localization Services | ||
|
||
To provide localization options, the context is using two abstractions. | ||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
One is using the Umbraco translations dictionary to retrieve a value based on a provided key. | ||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
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. | ||
Check warning on line 19 in 15/umbraco-ui-builder/collections/localization.md
|
||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Example | ||
|
||
For a `Students` collection we would use the following fluent configuration: | ||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```csharp | ||
treeConfig.AddCollection<Student>(x => x.Id, "#CollectionStudents", "#CollectionStudents", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig => | ||
{ | ||
... | ||
}); | ||
``` | ||
|
||
 | ||
|
||
Or | ||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```csharp | ||
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig => | ||
{ | ||
... | ||
}); | ||
``` | ||
|
||
acoumb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api"; | ||
|
||
export default { | ||
collection: { | ||
students: "Studerende" | ||
} | ||
... | ||
} | ||
``` | ||
|
||
 | ||
|
||
For a custom section we can use the following configuration: | ||
acoumb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
```csharp | ||
.AddSection("#UmbracoTraining", sectionConfig => | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
 | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
description: Using the available context to handle localization for an UI Builder collection | ||
--- | ||
|
||
# Localization | ||
|
||
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. | ||
Check warning on line 7 in 16/umbraco-ui-builder/collections/localization.md
|
||
|
||
To enable localization the input string must be prefixed by the `#` character. | ||
|
||
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. | ||
|
||
## Localization Services | ||
|
||
To provide localization options, the context is using two abstractions. | ||
|
||
One is using the Umbraco translations dictionary to retrieve a value based on a provided key. | ||
|
||
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. | ||
Check warning on line 19 in 16/umbraco-ui-builder/collections/localization.md
|
||
|
||
## Example | ||
|
||
For a `Students` collection we would use the following fluent configuration: | ||
|
||
```csharp | ||
treeConfig.AddCollection<Student>(x => x.Id, "#CollectionStudents", "#CollectionStudents", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig => | ||
{ | ||
... | ||
}); | ||
``` | ||
|
||
 | ||
|
||
Or | ||
|
||
```csharp | ||
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig => | ||
{ | ||
... | ||
}); | ||
``` | ||
|
||
``` | ||
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api"; | ||
|
||
export default { | ||
collection: { | ||
students: "Studerende" | ||
} | ||
... | ||
} | ||
``` | ||
|
||
 | ||
|
||
For a custom section we can use the following configuration: | ||
|
||
```csharp | ||
.AddSection("#UmbracoTraining", sectionConfig => | ||
{ | ||
... | ||
} | ||
``` | ||
|
||
 | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.