Giter Site home page Giter Site logo

nlocalizator's Introduction

Contributors Forks Stargazers Issues NuGet MIT License


NLocalizator

A Run-Time Localization Tool
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Roadmap
  4. Contributing
  5. License
  6. Contact

About The Project

This tool allows you to build a localization structure whose content can be changed at run-time.

(back to top)

Built With

.Net

(back to top)

Getting Started

Prerequisites

Installation

  • Add NLocalizator NuGet package to your project
dotnet add package NLocalizator

Usage

Create Language Files

Create *lang-name*.json file in project directory. This file name is in use configuration of the tool.

For example tr.json file:

{
	"Monday" : "Pazartesi",
	"Tuesday" : "Salı",
	"Wednesday" : "Çarşamba",
	"Thursday" : "Perşembe",
	"Friday" : "Cuma",
	"Saturday" : "Cumartesi",
	"Sunday" : "Pazar"
}
Create The LocalizationBook
using NLocalizator;

public class DaysLocalizationBook : ILocalizationBook
{
    public string Monday { get; set; }
    public string Tuesday { get; set; }
    public string Wednesday { get; set; }
    public string Thursday { get; set; }
    public string Friday { get; set; }
    public string Saturday { get; set; }
    public string Sunday { get; set; }
}
Dependency Injection
using NLocalizator;

builder.Services.AddLocalizator<DaysLocalizationBook>(options =>
    options.AddFolderPath(@"*the_folder_path_that_contains_tr.json_file*")
    .AddLanguage("tr"));
Call the Localizator
using NLocalizator;

public class WeatherForecastController : ControllerBase
{
    private readonly Localizator<DaysLocalizationBook> _daysLocalizator;

    public WeatherForecastController(Localizator<DaysLocalizationBook> daysLocalizator)
    {
        _daysLocalizator = daysLocalizator;
    }

    [HttpGet(Name = "GetToday")]
    public string Get()
    {
        var today = _daysLocalizator.GetByName("Monday");

        //or

        today = _daysLocalizator.LocalizationBook.Monday;

        return today;
    }
}
Change The Language
  • Make sure the new *lang-name*.json file be in the same folder with tr.json

de.json file:

{
	"Monday" : "Montag",
	"Tuesday" : "Deinstag",
	"Wednesday" : "Mittwoch",
	"Thursday" : "Donnerstag",
	"Friday" : "Freitag",
	"Saturday" : "Samstag",
	"Sunday" : "Sonntag"
}
  • Create a new post method in the controller
[HttpPost(Name = "SetLanguageToGerman")]
public bool SetLanguageToGerman()
{
    _daysLocalizator.ChangeLanguage("de");
    return true;
}

For more examples, please refer to the Sample Project

(back to top)

Roadmap

  • Add multi language support
  • Add multi LocalizationBook support
  • Add language change support
  • Add examples
  • Add license file
  • Add NuGet package
  • Add Changelog
  • Add structral comments for methods
  • Add tests

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.md for more information.

(back to top)

Contact

LinkedIn

Tolga Çakır - [email protected]

Project Link: https://github.com/adessoTurkey-dotNET/NLocalizator

(back to top)

nlocalizator's People

Contributors

tolgacakir avatar

Stargazers

Baransel Oral avatar Nurcan Kahya Ersolak avatar Ersin Gün avatar Umit AKINCI avatar Funda Özmen avatar Kaan Öztürk avatar Seyda Nur DEMIR avatar  avatar Bilgehan Berberoğlu avatar Nuri avatar

Watchers

 avatar Bilgehan Berberoğlu avatar Nuri avatar Funda Özmen avatar

nlocalizator's Issues

Compliance with localization information in list format

We can adjust nlocalizer for list of values and combine languages in a single json format.
Example of a list format is below:

[
{
    "Key":"Monday",
    "Values":{
        "tr-TR":"Pazartesi",
        "en-US":"Monday"
    }
},
{
    "Key":"Tuesday",
    "Values":{
        "tr-TR":"Salı",
        "en-US":"Tuesday"
    }
},
]

Thank you.

Add ui layer for editing localization data

UI development is required to edit the localization data used by the library or to add new ones. This ui layer should be added as middleware and endpoint can be /ui. We can take the ui side of libraries such as Hangfire or CAP as an example.

Storing Localization Data

Folder structure may be like this ->

Lang -> days.en.json, days.tr.json, weather.en.json, weather.tr.json

It might be better.

Add tests

The tests (specially concurrency tests) are needed.

Add reload support for data changes

This library should reload itself when localization data changed. For these feature we can use file watcher or IOptions approach. This will be great feature because after data changes applications doesn't need to restart.

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.