LazZiya.ExpressLocalization
3.1.3
See the version list below for details.
dotnet add package LazZiya.ExpressLocalization --version 3.1.3
NuGet\Install-Package LazZiya.ExpressLocalization -Version 3.1.3
<PackageReference Include="LazZiya.ExpressLocalization" Version="3.1.3" />
paket add LazZiya.ExpressLocalization --version 3.1.3
#r "nuget: LazZiya.ExpressLocalization, 3.1.3"
// Install LazZiya.ExpressLocalization as a Cake Addin #addin nuget:?package=LazZiya.ExpressLocalization&version=3.1.3 // Install LazZiya.ExpressLocalization as a Cake Tool #tool nuget:?package=LazZiya.ExpressLocalization&version=3.1.3
What is ExpressLocalization?
A nuget package to simplify the localization of any Asp.Net Core web app to one step only. All below localization settings in one clean step:
- Global route template: Add {culture} paramter to all routes, so urls will be like http://www.example.com/en-US/
- RouteValueRequestCultureProvider : Register route value request culture provider, so culture selection will be based on route value
- ViewLocalization : Use LocalizeTagHelper for localizing all razor pages depending on a shared resource. In order to use LocalizetagHelper LazZiya.TagHelpers.Localization must be installed separately.
- DataAnnotations Localization : All data annotations validation messages and display names attributes localization
- ModelBinding Localization : localize model binding error messages
- IdentityErrors Localization : localize identity describer error messages
- Client Side Validation : include all client side libraries for validating localized input fields like decimal numbers. This option requires LazZiya.TagHelpers package that will be installed automatically.
Installation
Install from nuget :
Install-Package LazZiya.ExpressLocalization
How to use
- Install from nuget as mention above
- Relevant localization resource files are available in LazZiya.ExpressLocalizationSample repo. Download the resources and add them to your main web project, or just create you own resource files with the relevant key names as in ExpressLocalizationResource.tr.resx file.
- In your main project' startup.cs file, define supported cultures list then add express localization setup in one step or customized steps as mentioned below
One step setup:
This step will add all localization settings :
//add reference to :
using LazZiya.ExpressLocalization;
//setup express localization under ConfigureServices method:
public void ConfigureServices(IServiceCollection services)
{
//other configuration settings....
var cultures = new CultureInfo[]
{
new CultureInfo("en"),
new CultureInfo("tr"),
new CultureInfo("ar")
};
services.AddRazorPages()
//ExpressLocalizationResource and ViewLocalizationResource are available in :
// https://github.com/LazZiya/ExpressLocalizationSample
.AddExpressLocalization<ExpressLocalizationResource, ViewLocalizationResource>(
exOps =>
{
exOps.ResourcesPath = "LocalizationResources";
exOps.RequestLocalizationOptions = ops =>
{
ops.SupportedCultures = cultures;
ops.SupportedUICultures = cultures;
ops.DefaultRequestCulture = new RequestCulture("en");
};
});
}
Then configure the app to use RequestLocalizationMiddleware :
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
//other codes...
//add localization middleware to the app
app.UseRequestLocalization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
if you are using Mvc just add the culture parameter to the route as below:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{culture=en}/{controller=Home}/{action=Index}/{id?}",
);
});
Also it is possible to add culture parameter to the route attributes as well:
[Route("{culture}/Home")]
public class HomeController : Controller {
// ...
}
For more details visit the repository GitHub page : https://github.com/LazZiya/ExpressLocalization
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. |
.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
- LazZiya.TagHelpers (>= 2.2.1)
- Microsoft.AspNetCore.Identity (>= 2.0.4)
- Microsoft.AspNetCore.Mvc.Localization (>= 2.0.0)
- Microsoft.AspNetCore.Mvc.RazorPages (>= 2.0.0)
-
.NETCoreApp 2.1
- LazZiya.TagHelpers (>= 2.2.1)
- Microsoft.AspNetCore.Identity (>= 2.0.4)
- Microsoft.AspNetCore.Mvc.Localization (>= 2.0.0)
- Microsoft.AspNetCore.Mvc.RazorPages (>= 2.0.0)
-
.NETCoreApp 2.2
- LazZiya.TagHelpers (>= 2.2.1)
- Microsoft.AspNetCore.Identity (>= 2.0.4)
- Microsoft.AspNetCore.Mvc.Localization (>= 2.0.0)
- Microsoft.AspNetCore.Mvc.RazorPages (>= 2.0.0)
-
.NETCoreApp 3.0
- LazZiya.TagHelpers (>= 3.0.0)
-
.NETCoreApp 3.1
- LazZiya.TagHelpers (>= 3.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on LazZiya.ExpressLocalization:
Repository | Stars |
---|---|
teduinternational/eShopSolution
eShopSolution is a tutorial solution for everyone using .NET Core 3.1
|
Version | Downloads | Last updated | |
---|---|---|---|
5.0.0-beta2 | 1,742 | 6/1/2020 | |
5.0.0-beta1 | 411 | 5/17/2020 | |
4.0.4 | 18,100 | 9/29/2020 | |
4.0.3 | 1,457 | 9/24/2020 | |
4.0.2 | 7,966 | 8/11/2020 | |
4.0.1 | 5,384 | 5/19/2020 | |
4.0.0 | 5,752 | 3/27/2020 | |
4.0.0-preview1 | 1,558 | 2/20/2020 | |
3.2.0 | 2,718 | 1/16/2020 | |
3.1.3 | 3,143 | 12/18/2019 | |
3.1.3-preview1 | 1,278 | 11/11/2019 | |
3.1.2 | 1,939 | 10/8/2019 | |
3.1.1 | 1,622 | 9/27/2019 | |
3.0.0 | 1,688 | 9/25/2019 | |
3.0.0-preview2 | 1,265 | 9/22/2019 | |
3.0.0-preview1 | 1,239 | 9/2/2019 | |
2.0.1 | 2,988 | 6/22/2019 | |
2.0.0 | 1,536 | 6/16/2019 | |
1.1.2 | 1,504 | 6/13/2019 | |
1.1.1 | 1,576 | 6/3/2019 | |
1.1.0 | 1,463 | 5/26/2019 | |
1.0.0 | 1,477 | 5/19/2019 |
- Support for DotNet Core 3.1