use Locale::Simple; l_dir('data/locale'); ltd('test'); l_lang('de_DE'); print l("Hello"); # "Hallo" print ln("You have %d message","You have %d messages",4); # 'Du hast 4 Nachrichten'
Sample PO file, in this case data/locale/test.po
msgid "" msgstr "" "Language: de_DE\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;" msgid "You have %d message" msgid_plural "You have %d messages" msgstr "Du hast %d Nachricht" msgstr "Du hast %d Nachrichten" msgid "Hello" msgstr "Hallo"
This is a small wrapper around Gettext functionality that integrates sprintf and makes it a bit more easy to setup the internationalization. It ONLY supports UTF8 data, and in or output, that is a fixed setup (and always will be).
Gettext in Perl requires compiled po files, so called mo files. You can generate those with the following command (if you have gettext in general installed on your system):
msgfmt -o data/locale/test.mo data/locale/test.po
echo -n "locale_data['test'] = " >data/locale/test.json po2json data/locale/test.po >>data/locale/test.json echo ";" >>data/locale/test.json
http://github.com/Getty/p5-locale-simple Pull request and additional contributors are welcome
Torsten Raudssus <email@example.com>
This software is copyright (c) 2012 by DuckDuckGo, Inc. http://duckduckgo.com/, Torsten Raudssus <firstname.lastname@example.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.