Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An internationalization library for JavaScript.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
LICENSE
README
i18n.js

README

i18njs, an internationalization library for JavaScript.
  http://github.com/jefftrudeau/i18njs

Released under the GNU General Public License, version 2.
  http://www.gnu.org/licenses/gpl-2.0.txt

Copyright (C) Jeff Trudeau

----------------
Supports one translation (.po) file per language, which should be named according to its applicable
browser locale, e.g., 'en-US.po'. If you want to split up your translations, just put the files in
different directories.

Include the i18n.js script in your page and call i18n.init('/path/to/po-files/') to load your
translations. To translate a string, use the String class' i18n() instance method.

Given the following .po file:

  msgid "This is an example string to be translated, with some tokens, '%s' and %d."
  msgstr "And here's the translated string, complete with '%s' and %s ;)"

And the following script:

  <script type="text/javascript" src="http://code.braeburntech.com/i18njs/i18n.min.js"></script>
  <script type="text/javascript">
    i18n.init('/po');
    alert("This is an example string to be translated, with some tokens, '%s' and %d.".i18n('token1', 2));
  </script>

The result will be the following alert message:

  And here's the translated string, complete with 'token1' and 2 ;)

----------------
TODO:

Support re-ordering of replacement tokens.
Something went wrong with that request. Please try again.