Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

NetCoreStack/Localization

Repository files navigation

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

NuGetNuGet

Links

Docker File

PM> docker pull tahaipek/netcorestack-localization-test-hostingPM> 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 inAppSettings.json:

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

Enable NetCoreStack.Localization in ASP.NET Core

publicvoidConfigureServices(IServiceCollectionservices){services.AddNetCoreStackMvc(options=>{options.AppName="NetCoreStack Localization";});services.AddNetCoreStackLocalization(Configuration);}
publicvoidConfigure(IApplicationBuilderapp,IHostingEnvironmentenv){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 ComboboxOptional:   - 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-languageSelectorname="culture"set-cookie-with-java-script="true"></netcorestack-languageSelector>@Localizer["Logo_Description"]</body>

Back-end Localization in *.cs file

publicclassHomeController:Controller{privatereadonlyIStringLocalizer_stringLocalizer;publicHomeController(IStringLocalizerstringLocalizer){_stringLocalizer=stringLocalizer;}publicIActionResultAbout(){ViewData["Message"]=_stringLocalizer["AboutPageDescription"];returnView();}}

Test Project Preview

How To UseForms & Validations
Component ApiClient-Side Localization
Exception LocalizationAjaxException Localization

.Net Core Localization

.Net Core Localization with Entity Framework

.Net Core Database Localization

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp