From 5baef69e009ca9172f3fbfb26cab8ae6764f3634 Mon Sep 17 00:00:00 2001 From: Adrian Cojocariu Date: Wed, 10 Dec 2025 15:45:44 +0200 Subject: [PATCH 1/2] Add additional localization documentation --- .../collections/localization.md | 48 ++++++++++++++++++ .../collections/localization.md | 50 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/16/umbraco-ui-builder/collections/localization.md b/16/umbraco-ui-builder/collections/localization.md index cf75145fd7f..4b8010b619a 100644 --- a/16/umbraco-ui-builder/collections/localization.md +++ b/16/umbraco-ui-builder/collections/localization.md @@ -10,6 +10,19 @@ 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. +Supported areas: + +* Collections - `Name` and `Description` properties. +* Data Views - only if the key is in a localization resource, not in the translation dictionary. **** document this!!! In the issue I will document how to inject and work with the LocalizationContext for access to both services. +* Collection filters - `Label` and `Description` properties. +* Cards +* Editor fields - `Label` and `Description` field properties. +* Fieldsets names +* Actions names +* Context Apps names +* Dashboards names +* Sections names + ## Localization Services The localization context uses two abstractions to provide localization options. @@ -68,4 +81,39 @@ For a custom section, use the following configuration: ![section_name](../images/section_name.png) +### Localizing an additional area + +In a scenario where a specific area is not covered by the implemented localization, you can update it directly in the fluent configuration by using the `LocalizationContext`. + +For example, this custom data view: + +```csharp +public class CommentStatusDataViewsBuilder : DataViewsBuilder +{ + private readonly LocalizationContext _localizationContext; + public CommentStatusDataViewsBuilder(LocalizationContext localizationContext) + { + _localizationContext = localizationContext; + } + public override IEnumerable GetDataViews() + { + yield return new DataViewSummary + { + Name = _localizationContext.TryLocalize("#dataView_All", out string localizedText) ? localizedText : string.Empty, + Alias = "all", + Group = "Status" + }; + + foreach (var val in Enum.GetValues()) + { + yield return new DataViewSummary + { + Name = val.ToString(), + Alias = val.ToString().ToLower(), + Group = "Status" + }; + } + } +} +``` diff --git a/17/umbraco-ui-builder/collections/localization.md b/17/umbraco-ui-builder/collections/localization.md index 2d745d7f295..c8c12a00bcb 100644 --- a/17/umbraco-ui-builder/collections/localization.md +++ b/17/umbraco-ui-builder/collections/localization.md @@ -10,6 +10,19 @@ 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. +Supported areas: + +* Collections - `Name` and `Description` properties. +* Data Views - only if the key is in a localization resource, not in the translation dictionary. **** document this!!! In the issue I will document how to inject and work with the LocalizationContext for access to both services. +* Collection filters - `Label` and `Description` properties. +* Cards +* Editor fields - `Label` and `Description` field properties. +* Fieldsets names +* Actions names +* Context Apps names +* Dashboards names +* Sections names + ## Localization Services The localization context uses two abstractions to provide localization options. @@ -68,4 +81,41 @@ For a custom section, use the following configuration: ![section_name](../images/section_name.png) +### Localizing an additional area + +In a scenario where a specific area is not covered by the implemented localization, you can update it directly in the fluent configuration by using the `LocalizationContext`. + +For example, this custom data view: + +```csharp +public class CommentStatusDataViewsBuilder : DataViewsBuilder +{ + private readonly LocalizationContext _localizationContext; + public CommentStatusDataViewsBuilder(LocalizationContext localizationContext) + { + _localizationContext = localizationContext; + } + + public override IEnumerable GetDataViews() + { + yield return new DataViewSummary + { + Name = _localizationContext.TryLocalize("#dataView_All", out string localizedText) ? localizedText : string.Empty, + Alias = "all", + Group = "Status" + }; + + foreach (var val in Enum.GetValues()) + { + yield return new DataViewSummary + { + Name = val.ToString(), + Alias = val.ToString().ToLower(), + Group = "Status" + }; + } + } +} +``` + From 96f13ec4cfa56ddb357c70ecd641f17da93f00de Mon Sep 17 00:00:00 2001 From: Adrian Cojocariu Date: Wed, 10 Dec 2025 15:51:00 +0200 Subject: [PATCH 2/2] Correct data views localization --- 16/umbraco-ui-builder/collections/localization.md | 2 +- 17/umbraco-ui-builder/collections/localization.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/16/umbraco-ui-builder/collections/localization.md b/16/umbraco-ui-builder/collections/localization.md index 4b8010b619a..3ff2f6ecfb3 100644 --- a/16/umbraco-ui-builder/collections/localization.md +++ b/16/umbraco-ui-builder/collections/localization.md @@ -13,7 +13,7 @@ Upon character identification in the fluent configuration, the localization cont Supported areas: * Collections - `Name` and `Description` properties. -* Data Views - only if the key is in a localization resource, not in the translation dictionary. **** document this!!! In the issue I will document how to inject and work with the LocalizationContext for access to both services. +* Data Views - only if the key is in a localization resource, not in the translation dictionary (e.g. [additional localization](#localizing-an-additional-area)). * Collection filters - `Label` and `Description` properties. * Cards * Editor fields - `Label` and `Description` field properties. diff --git a/17/umbraco-ui-builder/collections/localization.md b/17/umbraco-ui-builder/collections/localization.md index c8c12a00bcb..a94cf512003 100644 --- a/17/umbraco-ui-builder/collections/localization.md +++ b/17/umbraco-ui-builder/collections/localization.md @@ -13,7 +13,7 @@ Upon character identification in the fluent configuration, the localization cont Supported areas: * Collections - `Name` and `Description` properties. -* Data Views - only if the key is in a localization resource, not in the translation dictionary. **** document this!!! In the issue I will document how to inject and work with the LocalizationContext for access to both services. +* Data Views - only if the key is in a localization resource, not in the translation dictionary (e.g. [additional localization](#localizing-an-additional-area)). * Collection filters - `Label` and `Description` properties. * Cards * Editor fields - `Label` and `Description` field properties.