XLocalizer.TagHelpers
1.1.0
dotnet add package XLocalizer.TagHelpers --version 1.1.0
NuGet\Install-Package XLocalizer.TagHelpers -Version 1.1.0
<PackageReference Include="XLocalizer.TagHelpers" Version="1.1.0" />
<PackageVersion Include="XLocalizer.TagHelpers" Version="1.1.0" />
<PackageReference Include="XLocalizer.TagHelpers" />
paket add XLocalizer.TagHelpers --version 1.1.0
#r "nuget: XLocalizer.TagHelpers, 1.1.0"
#:package XLocalizer.TagHelpers@1.1.0
#addin nuget:?package=XLocalizer.TagHelpers&version=1.1.0
#tool nuget:?package=XLocalizer.TagHelpers&version=1.1.0
Localizing Views in Asp.Net Core Razor Pages
Read full docs at: docs.ziya.info.tr
XLocalizer has a handy extension pack; XLocalizer.TagHelpers for localizing views using a simple html tag.
Table of contents
- Install
- Setup
- Localize texts
- Localize HTML
- Localize Select Items
- Localize attributes
- Specify culture
- Provide arguments for localized contents
- Specify resource source
- Traditional localization for views
- Demo
- Next: Localizing data annotations
Install
Install from nuget
PM > Install-Package XLocalizer.TagHelpers
Setup
Localize views using LocalizeTagHelper, first it must be added to `ViewImports.cshtml
@addTagHelper *, XLocalizer.TagHelpers
Localize texts
Localize texts/html contents using localize-content attribute with any html tag
<h1 localize-content>Sample header</h1>
<p localize-content>
sample content...
</p>
Localize Html
Use <localize> html tag or to localize all its contents
<localize>
<h1>Sample title</h1>
<p>sample contents...</p>
<localize>
Localize Select Items
Use <localize-select> html tag to localize select items texts.
<localize-select asp-items="Model.MyItems"></localize-select>
Requires
XLocalizer.TagHelpers v1.1.0or later.
Localize attributes
Localize attributes like title inside <img tag using localize-att-*
<img src="/images/picture.jpg" localize-att-title="Picture title"/>
Provide arguments for localized contents
Localize a string that contains arguments by providing the arguments using localize-args
@{
var args = new object[] { "http://demo.ziyad.info/en/localize", 8, "Asp.Net Core" }
}
<p localize-args="args">
Visit <a href="{0}">demos website</a> to see a collection of {1} demos about "{2}".
</p>
Localized output sample: Visit demos website to see a collection of 8 demos about "Asp.Net Core".
Specify culture
Force specific culture regardless the request culture
<p localize-culture="tr">
This content will always be localized with TR culture
</p>
Specify resource source
Specify localization resource type using localize-source
<p localize-source="typeof(MyResourceType)">
This content will be localized from a specific shared resource.
</p>
See demo page.
Traditional localization for views
Default localization interfaces can be used to localize view contents:
@inject IStringLocalizer _localizer
<h1>@_localizer["Welcome"]</h1>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 is compatible. netcoreapp2.2 is compatible. netcoreapp3.0 is compatible. netcoreapp3.1 is compatible. |
-
.NETCoreApp 2.0
- Microsoft.AspNetCore.Mvc.TagHelpers (>= 2.0.0)
- XLocalizer (>= 1.0.0)
-
.NETCoreApp 2.1
- Microsoft.AspNetCore.Mvc.TagHelpers (>= 2.0.0)
- XLocalizer (>= 1.0.0)
-
.NETCoreApp 2.2
- Microsoft.AspNetCore.Mvc.TagHelpers (>= 2.0.0)
- XLocalizer (>= 1.0.0)
-
.NETCoreApp 3.0
- XLocalizer (>= 1.0.0)
-
.NETCoreApp 3.1
- XLocalizer (>= 1.0.0)
-
net5.0
- XLocalizer (>= 1.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on XLocalizer.TagHelpers:
| Package | Downloads |
|---|---|
|
XLocalizer.DB.UI
Interface for managing localization with XLocalizer package and ability to use online translation tools. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.0 | 12,436 | 8/31/2021 |
| 1.0.0 | 3,188 | 11/12/2020 |
| 1.0.0-rc.1 | 390 | 11/5/2020 |
| 1.0.0-preview1 | 970 | 7/26/2020 |
New: localize-select taghelper for localization of select items.
Docs: https://docs.ziyad.info/en/XLocalizer/v1.0/localizing-views.md
Release notes: https://github.com/LazZiya/XLocalizer.TagHelpers/releases