Internationalization library on top of jquery
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
jquery.i18n.js
jquery.inflector.js
jquery.interpolate.js
jquery.numbers.js
jquery.strftime.js

README.md

jquery.i18n

A javascript internationalization and localization solution. Originally based on the design of https://github.com/svecnfuchs/i18n/.

Requirements

  • jquery.strftime - Formats dates / times into human-readable text
  • jquery.numbers - Formats numbers into human readable-text
  • jquery.interpolate - Interpolates text that includes templated parameters
  • jquery.inflector - Helps transforms words from singular to plural and vice-versa
  • jquery.i18n - Core API for translating text and localizing dates / times

Usage

jQuery.i18.add('en-US', {
  good: {
    name: 'Good',
    color: 'color',
    designer: 'by {{name}}',
    credits: {
      one: '{{count}} credit',
      many: '{{count}} credits'
    }
  },
  user: {
    balance: {
      none: 'no credits',
      one: '{{count}} credit',
      many: '{{count}} credits'
    }
  }
});

jQuery.i18.add('en-GB', 'en-US', {
  good: {
    color: 'colour'
  }
});

jQuery.i18n.translate('name')                                   // >> "Name"
jQuery.i18n.translate('good.name')                              // >> "Good"
jQuery.i18n.translate('good.designer', {name: 'House Brand'});  // >> "by House Brand"
jQuery.i18n.translate('good.credits', {count: 0});              // >> "0 credits"
jQuery.i18n.translate('good.credits', {count: 1});              // >> "1 credit"
jQuery.i18n.translate('good.credits', {count: 2});              // >> "2 credits"
jQuery.i18n.translate('user.balance', {count: 0});              // >> "no credits"
jQuery.i18n.translate('user.balance', {count: 1});              // >> "1 credit"
jQuery.i18n.translate('user.balance', {count: 2});              // >> "2 credits"

See jquery.i18n source for more info.