• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

NetCoreStack/Localization:

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

NetCoreStack/Localization

开源软件地址(OpenSource Url):

https://github.com/NetCoreStack/Localization

开源编程语言(OpenSource Language):

C# 58.8%

开源软件介绍(OpenSource Introduction):

NetCoreStack Localization v1.0.6

Database Resource Localization for .NET Core with Entity Framework and In Memory Cache

NuGet NuGet

Links

Docker File

PM> docker pull tahaipek/netcorestack-localization-test-hosting
PM> docker run -d -p 5003:80 netcorestack-localization-test-hosting

Requirements:

  • .NET Core 2.1 or later
  • SQLite or MsSQL Server

Install for .NET Core

PM> Install-Package NetCoreStack.Localization

Features

  • .NET Core Resources in MsSql Server
  • Injectable .NET Core StringLocalizers
  • Serve Resources to JavaScript as JSON
  • Directly access and manage Languages/Resources with api and code

Installation

AppSettings Configuration

Configuration settings in AppSettings.json:

{
	"DbSettings": {
		"SqlConnectionString": "Server=.;Database=LocalizationTest;Trusted_Connection=True;MultipleActiveResultSets=true"
	},
	"LocalizationSettings": {
		"UseDefaultLanguageWhenValueIsNull": true
  	}
}

Enable NetCoreStack.Localization in ASP.NET Core

public void ConfigureServices(IServiceCollection services)
{
	services.AddNetCoreStackMvc(options => { options.AppName = "NetCoreStack Localization"; });
	services.AddNetCoreStackLocalization(Configuration);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
	app.UseNetCoreStackMvc();
	app.UseNetCoreStackLocalization();
}

Client-side localization in *.cshtml file

<head>
	<!-- Optional: The resources defined javascript. =>  "window.culture.resource"  -->
	<netcorestack-javascriptregistrar></netcorestack-javascriptregistrar>
    
	<!-- 
	Optional: 
	   - If you want cookies to be set by JavaScript, you should use this.   
	   - If you don't want cookies to be set by JavaScript, remove this line. It will automatically redirect to Controller Action.
	-->
	<netcorestack-languageSelector-scripts></netcorestack-languageSelector-scripts>
</head>
<body>
	<!--  
	Required: Language Selector Combobox
	Optional:
	   - If you want cookies to be set by JavaScript, you should set "set-cookie-with-java-script" property.   
	   - If you don't want cookies to be set by JavaScript, the application sets it through Controller Action.
	-->
	<netcorestack-languageSelector name="culture" set-cookie-with-java-script="true"></netcorestack-languageSelector>
	
	@Localizer["Logo_Description"]
</body>

Back-end Localization in *.cs file

public class HomeController : Controller
{
	private readonly IStringLocalizer _stringLocalizer;
	public HomeController(IStringLocalizer stringLocalizer)
	{
		_stringLocalizer = stringLocalizer;
	}

	public IActionResult About()
	{
		ViewData["Message"] = _stringLocalizer["AboutPageDescription"];
		return View();
	}
}

Test Project Preview

How To Use Forms & Validations
Component Api Client-Side Localization
Exception Localization AjaxException Localization

.Net Core Localization

.Net Core Localization with Entity Framework

.Net Core Database Localization




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap