![]() |
VOOZH | about |
dotnet add package XperienceCommunity.Localizer --version 13.5.5
NuGet\Install-Package XperienceCommunity.Localizer -Version 13.5.5
<PackageReference Include="XperienceCommunity.Localizer" Version="13.5.5" />
<PackageVersion Include="XperienceCommunity.Localizer" Version="13.5.5" />Directory.Packages.props
<PackageReference Include="XperienceCommunity.Localizer" />Project file
paket add XperienceCommunity.Localizer --version 13.5.5
#r "nuget: XperienceCommunity.Localizer, 13.5.5"
#:package XperienceCommunity.Localizer@13.5.5
#addin nuget:?package=XperienceCommunity.Localizer&version=13.5.5Install as a Cake Addin
#tool nuget:?package=XperienceCommunity.Localizer&version=13.5.5Install as a Cake Tool
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.
Kentico Xperience 13 (.net 5.0) required (minimum hotfix 5). To install...
XperienceCommunity.Localizer package into your MVC site services
.AddLocalization()
.AddXperienceLocalizer() // MUST call after AddLocalization() !
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>
.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
Resources under the root of your project.SharedResources.cs (namespace didn't seem to matter, but i put no namespace myself)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.
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. |
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 |
This package is not used by any popular GitHub repositories.
Fixed bug with Localization Strings containing {#} for string formatting, that it was not properly passing the string as is back.