Giter Site home page Giter Site logo

i18njs's Introduction

i18njs

Internationalisation library for JS projects

For more information, demo and examples please checkout http://i18njs.com

Available via npm as npm install roddeh-i18n

Use with TypeScript

i18njs comes with typings for TypeScript. To use these typings in your project, they have to be imported explicitly. Simply create a *.d.ts file in your project folder and add the following content to it:

declare module "roddeh-i18n" {
  import i18n from "roddeh-i18n/typings";
  export default i18n;
}

ogallagher-i18n features

Support promises as extension method returns

Both of the following patterns should work as of version 1.2.3:

const i18n = require('i18n')

const en = i18n.create({values: {
  '%n is even': {
    'even': 'yes, %n is even',
    'odd': 'no, %n is not even'
  }
}})

// existing pattern, extension as plain function
en.extend((text, num, formatting, data) => data[num % 2 === 0 ? 'even' : 'odd'])
console.log(en('%n is even', 2)) // yes, 2 is even

// new pattern, extension as simple promise
en.extend((text, num, formatting, data) => new Promise((res) => {
  res(data[num % 2 === 0 ? 'even' : 'odd'])
}))
en('%n is even', 2).then(console.log) // yes, 2 is even

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

  • Simon Rodwell - Initial work - roddeh

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

i18njs's People

Contributors

roddeh avatar ogallagher avatar entriphy avatar swionrdhw 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.