This is a simple Javascript library that provides internationalization functions.
How to use it
The following code shows how to use this library.
1) Include it in your HTML page.
<script src="simple-i18n.js"></script>
2) Define templates.
var data =
[
// [<Language>, <Template Name>, <Function to Execute>]
['pt', 'resourceText', function(n) { return n + ' Recursos'; }],
['en', 'resourceText', function(n) { return n + ' Resources'; }],
['pt', 'name', function(name) { return 'O meu nome é ' + name; }],
['en', 'name', function(name) { return 'My name is '+ name; }]
];
3) Create i18n instance and call templates.
var i18nInstance = i18nFactory(data);
var value = i18nInstance.get('pt').resourceText();
var value = i18nInstance.get('en').resourceText();
var value = i18nInstance.get('pt').name('John');
var value = i18nInstance.get('en').name('John');