po2json - Command line tool for converting a po file into a Gettext.js compatible json dataset
po2json /path/to/domain.po > domain.json
This takes a PO file, as is created from GNU Gettext's xgettext, and converts it into a JSON file.
echo -n "var json_locale_data = " > domain.json po2json /path/to/domain.po >> domain.json echo ";" >> domain.json
-p : pretty-print the output. Makes the output more human-readable.
Locale::PO has a potential bug (I don't know if this actually causes a problem or not). Given a .po file with an entry like:
msgid "" "some string" msgstr ""
When $po->dump is run on that entry, it will output:
msgid "some string" msgstr ""
The above is removing the first linebreak. I don't know if that is significant. If so, we'll have to rewrite using a different parser (or include our own parser).
Copyright (C) 2008, Joshua I. Miller <email@example.com>, all rights reserved. See the source code for details.
Torsten Raudssus <firstname.lastname@example.org>
This software is copyright (c) 2012 by DuckDuckGo, Inc. http://duckduckgo.com/, Torsten Raudssus <email@example.com>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.