-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
37 lines (25 loc) · 1.29 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.