Skip to content

kostia/jquery.li18n

Repository files navigation

Li18n

Lightweight i18n for jQuery.

Why?

  • It does exactly what it promises.
  • It is lightweight: less than 100 SLOC.
  • Full test coverage.
  • Well documented.

Features

  • Translation
  • Interpolation
  • Localization framework
  • Shortcuts
  • Fallbacks
  • Error handling

Installation

bower install jquery.li18n

Usage

$.li18n.translations = {de: {greeting: 'Hello %{{name}}!'}};
$.li18n.currentLocale = 'de'
$.li18n.translate('greeting', {name: 'Alice'}); // => 'Hello Alice!'
_t('greeting', {name: 'Alice'}); // => 'Hello Alice!'

Live example: http://jsfiddle.net/pf59z/2/

Documentation

Testing

You will need Node.js in order to run tests. On OSX you can install Node.js with Homebrew (http://brew.sh/).

Install dependecies

npm install
npm install -g bower
bower install

Run the tests

npm test

Building

npm install -g gulp
gulp build

Other i18n libraries

The following does not aim to be objective in any way, but only reflects my opinion.

Full-featured heavyweights

Lightweights

Contributing

License

The MIT License (MIT)

Copyright (c) 2014 Kostiantyn Kahanskyi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.