Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
71 changes: 71 additions & 0 deletions 15/umbraco-ui-builder/collections/localization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
description: Using the available context to handle localization for an UI Builder collection
---

# Localization

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.

To enable localization, prefix the input string with 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

The localization context uses two abstractions to provide localization options.

The first uses the Umbraco translations dictionary to retrieve a value based on a provided key.

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.

## Example

### Localizing a Collection

For a `Students` collection, 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)

Alternatively, you can use the lowercase version:

```csharp
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
{
...
});
```

Define the translation in your localization dictionary file:
```
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api";

export default {
collection: {
students: "Studerende"
}
...
}
```

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

### Localizing a Section
For a custom section, 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
71 changes: 71 additions & 0 deletions 16/umbraco-ui-builder/collections/localization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
description: Using the available context to handle localization for an UI Builder collection
---

# Localization

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.

To enable localization, prefix the input string with 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

The localization context uses two abstractions to provide localization options.

The first uses the Umbraco translations dictionary to retrieve a value based on a provided key.

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.

## Example

### Localizing a Collection

For a `Students` collection, 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)

Alternatively, you can use the lowercase version:

```csharp
treeConfig.AddCollection<Student>(x => x.Id, "#collection_students", "#collection_students", "A list of students", "icon-umb-members", "icon-umb-members", collectionConfig =>
{
...
});
```

Define the translation in your localization dictionary file:
```
import type { UmbLocalizationDictionary } from "@umbraco-cms/backoffice/localization-api";

export default {
collection: {
students: "Studerende"
}
...
}
```

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

### Localizing a Section
For a custom section, 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.