XperienceCommunity.Localization
1.2.2-pre.107ba0f
See the version list below for details.
dotnet add package XperienceCommunity.Localization --version 1.2.2-pre.107ba0f
NuGet\Install-Package XperienceCommunity.Localization -Version 1.2.2-pre.107ba0f
<PackageReference Include="XperienceCommunity.Localization" Version="1.2.2-pre.107ba0f" />
paket add XperienceCommunity.Localization --version 1.2.2-pre.107ba0f
#r "nuget: XperienceCommunity.Localization, 1.2.2-pre.107ba0f"
// Install XperienceCommunity.Localization as a Cake Addin #addin nuget:?package=XperienceCommunity.Localization&version=1.2.2-pre.107ba0f&prerelease // Install XperienceCommunity.Localization as a Cake Tool #tool nuget:?package=XperienceCommunity.Localization&version=1.2.2-pre.107ba0f&prerelease
XperienceCommunity.Localization
Description
This project enables creating and using localizations and translations in Xperience by Kentico project. Create translations in Xperience admin UI or programatically and use in your pages.
Screenshots
Library Version Matrix
Xperience Version | Library Version |
---|---|
>= 29.2.0 | >= 1.2.0 |
>= 28.4.3 | 1.0.0 |
Dependencies
Package Installation
Add the package to your application using the .NET CLI
dotnet add package XperienceCommunity.Localization
Quick Start
Add this library to the application services.
// Program.cs builder.Services.AddXperienceCommunityLocalization();
Open the Localization application added by this library in the Xperience's Administration.
Press Create to add a localization.
Fill out the key and the description of the localized content.
Add translations for the desired content languages.
Display the results on your site with a
ViewComponent
.
// ViewModelLocalizedWidgetViewComponent.cs
private readonly IKenticoStringLocalizer localizer;
public ViewModelLocalizedWidgetViewComponent(IKenticoStringLocalizer localizer)
=> this.localizer = localizer;
public IViewComponentResult Invoke()
{
var model = new ViewModelLocalizedWidgetViewModel
{
Title = localizer["Title"],
Content = localizer["Content"]
};
return View("~/Components/Widgets/ViewModelLocalizedWidget/_ViewModelLocalizedWidget.cshtml", model);
}
- Or display the results on your site with a Razor View 👍
@using XperienceCommunity.Localization
@inject IKenticoHtmlLocalizer localizer
<div>
<h1>@localizer["Title"]</h1>
<p>@localizer["Content"]</p>
</div>
Customization
Administration does not allow for storing empty string values as the translations. By default, if a specified key in a specified language does not exist the name of the key is returned.
You can override this functionality by specifying your own implmentation of IKenticoHtmlLocalizer
and IKenticoStringLocalizer
. Default implementations are the KenticoHtmlLocalizer
and the KenticoStringLocalizer
.
This can be useful if you want to display a value in one language and display nothing in a different language.
To achieve this, you can inherit the KenticoHtmlLocalizer
or the KenticoStringLocalizer
.
public class ExampleHtmlLocalizer : KenticoHtmlLocalizer
{
public override string? GetStringByName(string name)
{
string culture = CultureInfo.CurrentCulture.ToString();
// return empty string instead of null.
return localizationService.GetValueByNameAndCulture(name, culture) ?? string.Empty;
}
}
Similarly implement the IKenticoStringLocalizer
, or use the default KenticoStringLocalizer
// In your Program.cs
// ... Other registrations
builder.Services.AddXperienceCommunityLocalization<ExampleHtmlLocalizer, KenticoStringLocalizer>();
Contributing
Instructions and technical details for contributing to this project can be found in Contributing Setup.
License
Distributed under the MIT License. See LICENSE.md
for more information.
Support
This project has Limited support.
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
- Kentico.Xperience.Admin (>= 29.2.0)
- Kentico.Xperience.Core (>= 29.2.0)
- Kentico.Xperience.WebApp (>= 29.2.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.4.1 | 129 | 10/18/2024 |
1.4.1-pre.9c79180 | 65 | 10/18/2024 |
1.4.1-pre.782df4b | 61 | 10/18/2024 |
1.4.1-pre.501b2b6 | 61 | 10/18/2024 |
1.2.2 | 237 | 7/11/2024 |
1.2.2-pre.e63914d | 65 | 10/18/2024 |
1.2.2-pre.95a5373 | 34 | 7/11/2024 |
1.2.2-pre.8fa780a | 48 | 7/11/2024 |
1.2.2-pre.614044a | 60 | 10/18/2024 |
1.2.2-pre.2a9f442 | 63 | 10/18/2024 |
1.2.2-pre.107ba0f | 32 | 7/11/2024 |
1.2.1 | 82 | 7/11/2024 |
1.2.1-pre.db6a0d4 | 47 | 7/11/2024 |
1.2.1-pre.8fa780a | 45 | 7/11/2024 |
1.1.1 | 322 | 5/15/2024 |
1.1.1-pre.5b89503 | 49 | 5/14/2024 |
1.1.1-pre.2aea3c9 | 36 | 7/11/2024 |
1.0.7-pre.bb77ad6 | 53 | 5/14/2024 |
1.0.7-pre.903c108 | 56 | 5/14/2024 |
1.0.6 | 102 | 5/14/2024 |
1.0.6-pre.bb77ad6 | 48 | 5/14/2024 |
1.0.4 | 95 | 5/14/2024 |
1.0.4-pre.5b89503 | 42 | 5/14/2024 |