Coder Social home page Coder Social logo

translawesome's Introduction

Translawesome

Library that provides the basic structure for managing translations from the desired source (custom providers: JSON files, InMemory database, MySQL, SQL Server, SQLite, ...) generating JSON files to be easily used in Angular (for example).

Usage

Translawesome is a .NET Standard 2.0 library.

1. Create your own provider and cache services

To avoid a lot of I/O operations, a cache service has been taken in care. Obviously every project has their needs and so you (developer) have to take care of this. In the demo project (ASP.NET Core) a MemoryCache has been implemented.

The developer needs to implement his wanted translation provider (for example from JSON files or from another desired source).

2. Register your providers

After you implemented your own providers, you obviously need to register them for dependency injection.

Example:

 services.AddScoped<ITranslationProvider, MyCustomTranslationProvider>();
 services.AddScoped<ICacheService, MyMemoryCacheService>();

3. Register Translawesome service

Next you added your own providers, you need to register the Translawesome service.

 services.AddScoped<ITranslawesomeService, TranslawesomeService>();

4. Use it as you want

You can now inject the TranslawesomeService where you need to use it.

Example:

namespace ch.igorgiovannini.Translawesome.Demo.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TranslationsController : ControllerBase
    {
        private readonly ITranslawesomeService _translawesomeService;

        public TranslationsController(ITranslawesomeService translawesomeService) {
            _translawesomeService = translawesomeService;
        }
    }
}

License

MIT

translawesome's People

Contributors

igorgiovannini avatar

Stargazers

Sergio Aquilini avatar Mirko avatar Alessio Dionisi avatar

Watchers

 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.