VOOZH about

URL: https://www.nuget.org/packages/XperienceCommunity.Localizer/

⇱ NuGet Gallery | XperienceCommunity.Localizer 13.5.5




👁 Image
XperienceCommunity.Localizer 13.5.5

dotnet add package XperienceCommunity.Localizer --version 13.5.5
 
 
NuGet\Install-Package XperienceCommunity.Localizer -Version 13.5.5
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XperienceCommunity.Localizer" Version="13.5.5" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XperienceCommunity.Localizer" Version="13.5.5" />
 
Directory.Packages.props
<PackageReference Include="XperienceCommunity.Localizer" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XperienceCommunity.Localizer --version 13.5.5
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: XperienceCommunity.Localizer, 13.5.5"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XperienceCommunity.Localizer@13.5.5
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XperienceCommunity.Localizer&version=13.5.5
 
Install as a Cake Addin
#tool nuget:?package=XperienceCommunity.Localizer&version=13.5.5
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

XperienceCommunity.Localizer

Adds fallback support of Kentico Xperience's Localization keys/translations to the default IHtmlLocalizer/IStringLocalizer/IViewLocalizer)

In the past, most translation keys / translations were controlled through Kentico Xperience's Localization → Resource strings. This allowed users to create keys and translate them, with fall back to the default language.

This package restores that functionality, while allowing normal .resx resource file translations.

Installation and Requirements

Kentico Xperience 13 (.net 5.0) required (minimum hotfix 5). To install...

  1. Install the XperienceCommunity.Localizer package into your MVC site
  2. add this line of code in your startup
	services
		.AddLocalization()
 .AddXperienceLocalizer() // MUST call after AddLocalization() !

Usage

Use IHtmlLocalizer<> / IStringLocalizer<> as you would normally. Now you also can put in Kentico Xperience Localization macros in your strings as well. Here's some examples:

@inject IHtmlLocalizer<SharedResources> HtmlLocalizer;

<p>@HtmlLocalizer["myresource.key"]</p>
<p>@HtmlLocalizer.GetString("{$ general.greeting $}") Bob</p>

Resx help

.Net core can be confusing for resource file placement...very confusing. So let me lay out what i have:

In Startup

services.AddLocalization()
	.AddXperienceLocalizer() // Call after AddLocalization, adds Kentico Resource String support
	.AddControllersWithViews()
	.AddViewLocalization() // honestly couldn't get View Localization to ever work...
	.AddDataAnnotationsLocalization(options =>
	 {
	 options.DataAnnotationLocalizerProvider = (type, factory) =>
	 {
		 // This will use your ~/Resources/SharedResources.resx, with kentico fall back
	 return factory.Create(typeof(SharedResources));
	 };
	 });

In your Project

  1. Create a folder Resources under the root of your project.
  2. Create a class SharedResources.cs (namespace didn't seem to matter, but i put no namespace myself)
  3. Create a SharedResources.resx for your default translations, SharedResources.en.resx for your language translations, and SharedResources.en-US.resx for your culture specific language translations.

Logic will prefer the .language-Region.resx first, then the .language.resx second, then .resx third, and lastly it will use Xperience's Localization Resource Strings (matching language-Region first followed by site default).

Other Resource Files You can also add resource files specifically for certain areas, for example if you have a View Component /Components/MyThing/MyThingViewComponent , you can place a MyThingViewComponent.resx in the same folder as your class, and call IHtmlLocalizer<MyThingViewComponent> componentLocalizer and it should use that, and still fall back to Xperience's Localization Resource Strings.

Contributions, bug fixes and License

Thanks to Sean Wright for some more help on this one.

Feel free to Fork and submit pull requests to contribute.

You can submit bugs through the issue list and i will get to them as soon as i can, unless you want to fix it yourself and submit a pull request!

Check the License.txt for License information

Product Versions Compatible and additional computed target framework versions.
.NET net5.0 net5.0 is compatible.  net5.0-windows net5.0-windows was computed.  net6.0 net6.0 was computed.  net6.0-android net6.0-android was computed.  net6.0-ios net6.0-ios was computed.  net6.0-maccatalyst net6.0-maccatalyst was computed.  net6.0-macos net6.0-macos was computed.  net6.0-tvos net6.0-tvos was computed.  net6.0-windows net6.0-windows was computed.  net7.0 net7.0 was computed.  net7.0-android net7.0-android was computed.  net7.0-ios net7.0-ios was computed.  net7.0-maccatalyst net7.0-maccatalyst was computed.  net7.0-macos net7.0-macos was computed.  net7.0-tvos net7.0-tvos was computed.  net7.0-windows net7.0-windows was computed.  net8.0 net8.0 was computed.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 was computed.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 was computed.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on XperienceCommunity.Localizer:

Package Downloads
XperienceCommunity.Baseline.Localization.Library.KX13

The Baseline a set of Core Systems, Tools, and Structure to ensure a superior Kentico Website that's easy to migrate, for Kentico Xperience 13 and eventually Xperience by Kentico

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
13.5.5 4,515 9/22/2023
13.5.5-beta 249 9/22/2023
13.5.4 4,357 2/1/2023
13.5.3 445 1/31/2023
13.5.2 485 1/24/2023
13.5.1 3,815 10/12/2022
13.5.0 10,364 12/30/2021

Fixed bug with Localization Strings containing {#} for string formatting, that it was not properly passing the string as is back.