Coder Social home page Coder Social logo

ajunlonglive / ttag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ttag-org/ttag

0.0 1.0 0.0 2.85 MB

:orange_book: simple approach for javascript localization

Home Page: https://ttag.js.org/

License: MIT License

JavaScript 97.18% CSS 0.68% TypeScript 2.15%

ttag's Introduction

ttag

Modern javascript i18n localization library based on ES6 tagged templates and the good old GNU gettext

travis codecov downloads

NPM


Key features

  • Uses ES6 template literals for string formatting (no need for sprintf).
  • Contexts support
  • It can precompile translations on a build step.
  • Plurals support ngettext.
  • It can be integrated in any build tool that works with babel.
  • Has a builtin validation for translated strings format.
  • It can use any default locale in sources (not only English).
  • Handles React (jsx) translations.
  • Can be easily integrated with Create React App. CRA doc

Usage example

import { t, ngettext, msgid } from 'ttag'

// formatted strings
const name = 'Mike';
const helloMike = t`Hello ${name}`;

// plurals (works for en locale out of the box)
const n = 5;
const msg = ngettext(msgid`${ n } task left`, `${ n } tasks left`, n)

Installation

npm install --save ttag

CLI

You may also need to install ttag-cli for po files manipulation.

ttag cli - https://github.com/ttag-org/ttag-cli

npm install --save-dev ttag-cli

Usage from CDN

https://unpkg.com/ttag/dist/ttag.min.js

This project is designed to work in pair with babel-plugin-ttag.
But you can also play with it without transpilation.

Support

Give a ⭐️ if this project helped you!

Useful links

Slides from talks

Talks

License

This project is licensed under the MIT license.

ttag's People

Contributors

alexmost avatar oleksandr-kuzmenko avatar erickwilder avatar mrorz avatar eckertalex avatar vitaly-om avatar jaredh159 avatar aler9 avatar orkon avatar acro5piano avatar spacek33z avatar oleksmarkh avatar paulrosenzweig avatar timgates42 avatar dependabot[bot] avatar mmso 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.