GithubHelp home page GithubHelp logo

ggangix / factorial-i18n Goto Github PK

View Code? Open in Web Editor NEW

This project forked from factorialco/factorial-i18n

0.0 0.0 0.0 523 KB

I18n library for Factorial

License: MIT License

JavaScript 10.71% TypeScript 89.29%

factorial-i18n's Introduction

Factorial i18n

Minimal library for dealing i18n. Supports pluralization and interpolation.

Build Status JavaScript Style Guide

Installation

npm install factorial-i18n --save
yarn add factorial-i18n

Example

const translations = {
  en: {
    common: { hello: 'hello %{name}', },
    beers: { one: '%{count} beer', other: '%{count} beers' }
  },
  es: {
    common: { hello: 'hola %{name}', },
    beers: { one: '%{count} cerveza', other: '%{count} cervezas' }
  }
}

const i18n = new I18n()

i18n.setTranslations(translations)
i18n.setLocale('es')
i18n.t('common.hello') // => Hola
i18n.tp('common.beers', { count: 0 }) // => 0 cervezas
i18n.tp('common.beers', { count: 1 }) // => 1 cerveza

Where is it used?

Developed and battle tested in production in Factorial

factorial-i18n's People

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.