I've taken some time to rewrite a small Gettext library that I have written a while ago for a JavaScript Gettext editor I have made. The parsing algorithm was weak, so I've completely re-factored it and added some functionalities. If you want to take a peak to the latest source code here it is (prototype framework required).
Eventually I might add the editor to the project, but it need a good code refactoring too.
Here's a screen shot of the debug console:
The po files are dynamically loaded on load using link tags:
<head>
<link rel="gettext" lang="de" href="locale/de_test.po" />
</head>
After the library can be used like this:
Gettext.lang = 'de';
alert( _('The world is full of married men, %d','5') );
// or with a tuple-like second argument:
alert( _('%d hour, %d minutes and %d seconds',[hour, min, sec]) );
Please note that this library is still in development, only the basic functionalities of Gettext are implemented and some might be buggy or incomplete.
Currently the code is only available on Google code's repository, you can checkout the trunk anonymously with this command:
svn checkout http://gettext-js.googlecode.com/svn/trunk/ gettext-js
Feel free to give me feed backs or report bugs, if someone is interested in participating in this project, it's probably the only project for which I' will accept other coders.
Sorry no documentation yet, this is more a preview than a release.
no comments :|