Coder Social home page Coder Social logo

uzbekdev1 / localization-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netcorestack/localization

0.0 0.0 0.0 1.01 MB

๐ŸŒ Database Resource Localization for .NET Core with Entity Framework and In Memory Cache

Home Page: https://netcorestack.github.io/Localization/

License: MIT License

C# 58.81% CSS 1.25% JavaScript 0.02% PLpgSQL 16.95% HTML 22.86% Dockerfile 0.11%

localization-1's 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

localization-1's People

Contributors

gencebay avatar tahaipek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.