Giter Site home page Giter Site logo

eighteen's Introduction

Eighteen

A simple, elegant, i18n library for ReactJS.

Principles

Eighteen is written to get out of your way, make internationalisation of your React apps easy, and keep your code readable.

It's light, and has no dependencies.

Get Started

Install Eighteen:

npm install --save eighteen

Configure:

import Eighteen from 'eighteen';

Eighteen.configure({
  locales: {
    'fr-FR': {
      'Hello': 'Bonjour'
    }
  }
});

Use:

import { Text } from 'eighteen';

class MyComponent extends Component {
  render() {
    return (
      <Text locale="fr-FR">Hello</Text>
    );
    // Renders:
    // <span>Bonjour</span>
  }
}

Configuration

Eighteen.configure takes the following options.

locales (Object)

An object, where each key is the locale identifier (e.g. en-GB) and the values are a key-value list of translations.

Translations are keyed by the default translation, and the value is the locale-specific translation. For example, if your default translation is en-GB, your fr-FR configuration might look like this:

locales: {
  'fr-FR': {
    'Hello': 'Bonjour'
  }
}

defaultLocale (string)

The default locale key to use when a locale prop is not passed to the Test component.

Advanced Formatting

You can provided advanced formatting for your translations by providing an args which replaces the format indicators in the order they are given.

<Text args={[ 1 ]}>You have %s new message(s)</Text>
// <span>You have 1 new message(s)</span>

eighteen's People

Contributors

gpmcadam avatar

Stargazers

 avatar

Watchers

 avatar

eighteen's Issues

add continuous integration

  • automatically run tests, coverage and any build steps on PRs
  • automatically run publish to npmjs on build of master

add badges

  • coverage report
  • build status
  • npmjs link
  • others?

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.