Our.Umbraco.DictionaryLocalizer
1.0.3
dotnet add package Our.Umbraco.DictionaryLocalizer --version 1.0.3
NuGet\Install-Package Our.Umbraco.DictionaryLocalizer -Version 1.0.3
<PackageReference Include="Our.Umbraco.DictionaryLocalizer" Version="1.0.3" />
paket add Our.Umbraco.DictionaryLocalizer --version 1.0.3
#r "nuget: Our.Umbraco.DictionaryLocalizer, 1.0.3"
// Install Our.Umbraco.DictionaryLocalizer as a Cake Addin #addin nuget:?package=Our.Umbraco.DictionaryLocalizer&version=1.0.3 // Install Our.Umbraco.DictionaryLocalizer as a Cake Tool #tool nuget:?package=Our.Umbraco.DictionaryLocalizer&version=1.0.3
Our.Umbraco.DictionaryLocalizerPackage
This package adds Umbraco-dictionary based localisation e. g. models DataAnnotations.
Just prefix the name or error message with: #
public class MyModel
{
[Dislpay(Name = "#nameLabel")]
[Required(ErrorMessage = "#nameRequired")]
public string Name { get; set; }
[Dislpay(Name = "#emailLabel")]
[EmailAddress(ErrorMessage = "#emailInvalid")]
[Required(ErrorMessage = "#emailRequired")]
public string Email { get; set; }
...
}
In Back-Office section Translations add items: nameLabel, emailLabel, nameRequired, emailInvalid etc.
Umbraco version 10.x issue
For version 10.1+ the localizer will only work for ModelsBuilder generated models. Otherwise the [Dislpay(Name = "#nameLabel")]
translations will not work. This issue seems to be fixed in version 11. Version 10.0.0 and 10.0.1 do not handle [Dislpay(Name = "#nameLabel")]
at all. But as a work-a-round you can use dictionary items directly in tag helpers.
You find two projects Umbraco10.Website
version 10.3.2 and Umbraco11.Website
showing a simple form in two languages. Open solution OurDictionaryLocalizerWebiste.sln
, select one .Website and run Debug command. The interesting part is in Models\ContactFormModel.cs
.
Back-Office login: dirk.seefeld@idseefeld.de
and Test!23456
Runtime optimization
You can inherit your models from Our.Umbraco.DictionaryLocalizer.Models.DictionaryDataAnnotationBaseModel
and add the following to the appSettings.json:
"DictionaryLocalization": {
"DataAnnotationOnly": true
}
Now Our.Umbraco.DictionaryLocalizerPackage is only registered or invoked for these model classes. This might also help mitigating conflicts too.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Umbraco.Cms (>= 10.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.3 | 1,510 | 12/1/2022 |
Full support in Umbarco version 10.1.0. Previous version ignore [Display(Name="#nameLabel")]