在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):NetCoreStack/Localization开源软件地址(OpenSource Url):https://github.com/NetCoreStack/Localization开源编程语言(OpenSource Language):C# 58.8%开源软件介绍(OpenSource Introduction):NetCoreStack Localization v1.0.6Database Resource Localization for .NET Core with Entity Framework and In Memory CacheLinks
Docker File
Requirements:
Install for .NET Core
Features
InstallationAppSettings ConfigurationConfiguration settings in {
"DbSettings": {
"SqlConnectionString": "Server=.;Database=LocalizationTest;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"LocalizationSettings": {
"UseDefaultLanguageWhenValueIsNull": true
}
} Enable NetCoreStack.Localization in ASP.NET Corepublic 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 filepublic 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
.Net Core Localization.Net Core Localization with Entity Framework.Net Core Database Localization |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论