Skip to content
Use html tag to localize texts and html contents in razor views
C#
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LazZiya.TagHelpers.Localization
.gitattributes
.gitignore Add .gitignore and .gitattributes. Jun 13, 2019
README.md
TagHelpers.Localization.sln Add project files. Jun 13, 2019

README.md

LazZiya.TagHelpers.Localization

Use html tag to localize texts and html contents in razor pages for Asp.Net Core 2.x web applications

Installation

Install-Package LazZiya.TagHelpers.Localization -Version 1.0.0

Then inject localize tag helper in _ViewImports.cshtml file

using LazZiya.TagHelpers.Localization
addTagHelpers *, LazZiya.TagHelpers.Localization

Localize TagHelper Usage

Use localize tag directly:

<localize>Hellow world!</localize>

Use localize attributes in any html tag:

<h1 localize-content>Hello world!</h1>

Localize html contents:

<div localize-content>
    <h2>Title</h2>
    <p>Details...</p>
</div>

Use localization args:

<p localize-args="@(new object[] { 123, DateTime.Now })">
    The number is {0}, the date is {1}
</p>

Localize attributes e.g. alt attribute:

<img src="/images/lost-image.png" localize-att-alt="Cake and juice image" />

dependencies

Two nuget packages will be installed automatically with TagHelpers.Localization :

Check for updates after install.

Localization Setup

In order for localize tag helper to work the localization setup must be done in startup.cs as described in LazZiya.ExpressLocalization

Live demos:

http://demo.ziyad.info/en/localize

You can’t perform that action at this time.