Apache2-PageKit

 view release on metacpan or  search on metacpan

eg/contrib/locale/README  view on Meta::CPAN


lets perl do the work!

cd to_the_example_site;
./contrib/bin/build_locale.pl `pwd`

this creates all possible message catalogs from the dir .../locale/templates/po/
and install them in the right place.

How to build a compiled message file (.mo) manual?

first cd into the po_templates directory and copy the file
empty.po to your_lang.po i.e. cp empty.po de.po
the translate it. for all your messages add a

msgid "Hello World" and a
msgstr "Hallo Welt" line with the translation

if done call msgfmt to build the .mo file.

msgfmt -o de.mo de.po

then copy the file de.mo into the pkit_root/locale/de/LC_MESSAGES directory.

thats all.

with this patch pkit have locale info. This is very usefull for
languages != en for obvious reason but also for en. with this you
can have some sites with different messages four the same thing.

like: "You logged in succsesfully." on one site and
"You are welcome." on the other.

also all messages form the pkit_validate_input are translated.

use_locale = 'yes' in the global config part of the Config.xml file activates
the use of the locale info you provide. You need the module Locale::gettext
1.01. if reload = 'yes' (from the server config part) then the .mo files
are reread on every request. else only on serverstartup or first usage.

the API:

pkit_gettext($text);
	translate the text $text and return the translated text.
	if the text cant be translated, the original text is returned.

and pkit_gettext_message($text,...);
	this is a shortcut for
$model->pkit_message($model->pkit_gettext($text),...);


what to do?
copy your locale files into the directory
pkit_root/locale/*YOUR_LANG*/LC_MESSAGES/MyPageKit.mo where *YOUR_LANG*
should be replaced with your language shortcut from the ISO 639 standard.

here some i know of.

en English
de German
fr French
es Spanish
ga Irish
it Italian
zu Zulu

and MyPageKit should be replaced with the name of your pkit application.

so for my internal site pkit.brain.de with the dispatch class MyPageKit::MyModel

../htdocs/pkit.brain.de/locale/de/LC_MESSAGES/PageKit.mo
../htdocs/pkit.brain.de/locale/en/LC_MESSAGES/PageKit.mo

the .mo files are created with the msgfmt commandline tool form your PageKit.po
file.
A simple one is here:

######## start of file

domain "PageKit.mo"

#
# Apache2::PageKit
#

msgid "You have successfully logged in."
msgstr "Erfolgreich eingeloggt."

msgid "You have successfully logged out."
msgstr "Erfolgreich ausgeloggt."

msgid "Cookies must be enabled in your browser."
msgstr "Im Browser müssen Cookies eingeschaltet sein."



( run in 1.925 second using v1.01-cache-2.11-cpan-39bf76dae61 )