Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 15/umbraco-ui-builder/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
* [Retrieve Child Collections](collections/retrieve-child-collections.md)
* [Related Collections](collections/related-collections.md)
* [Entity Identifier Converters](collections/entity-identifier-converters.md)
* [Localization](collections/localization.md)

## Searching

Expand Down
67 changes: 67 additions & 0 deletions 15/umbraco-ui-builder/collections/localization.md
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

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐢 [UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content. Raw Output: {"message": "[UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content.", "location": {"path": "15/umbraco-ui-builder/collections/localization.md", "range": {"start": {"line": 7, "column": 1}}}, "severity": "WARNING"}

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 15/umbraco-ui-builder/collections/localization.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐢 [UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content. Raw Output: {"message": "[UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content.", "location": {"path": "15/umbraco-ui-builder/collections/localization.md", "range": {"start": {"line": 19, "column": 1}}}, "severity": "WARNING"}

## 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 =>
{
...
});
```

![collection_translation](../images/collection_translation.png)

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"
}
...
}
```

![collection_name](../images/collection_name.png)

For a custom section we can use the following configuration:

```csharp
.AddSection("#UmbracoTraining", sectionConfig =>
{
...
}
```

![section_name](../images/section_name.png)


Binary file added 15/umbraco-ui-builder/images/collection_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 15/umbraco-ui-builder/images/section_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions 16/umbraco-ui-builder/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* [Retrieve Child Collections](collections/retrieve-child-collections.md)
* [Related Collections](collections/related-collections.md)
* [Entity Identifier Converters](collections/entity-identifier-converters.md)
* [Localization](collections/localization.md)

## Searching

Expand Down
67 changes: 67 additions & 0 deletions 16/umbraco-ui-builder/collections/localization.md
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

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐢 [UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content. Raw Output: {"message": "[UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content.", "location": {"path": "16/umbraco-ui-builder/collections/localization.md", "range": {"start": {"line": 7, "column": 1}}}, "severity": "WARNING"}

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

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐢 [UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content. Raw Output: {"message": "[UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content.", "location": {"path": "16/umbraco-ui-builder/collections/localization.md", "range": {"start": {"line": 19, "column": 1}}}, "severity": "WARNING"}

## 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 =>
{
...
});
```

![collection_translation](../images/collection_translation.png)

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"
}
...
}
```

![collection_name](../images/collection_name.png)

For a custom section we can use the following configuration:

```csharp
.AddSection("#UmbracoTraining", sectionConfig =>
{
...
}
```

![section_name](../images/section_name.png)


Binary file added 16/umbraco-ui-builder/images/collection_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 16/umbraco-ui-builder/images/section_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading