Skip to content

jefftrudeau/i18njs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

An internationalization library for JavaScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published