Silver Light Silver Light - 3 years ago 176
PHP Question

PHP: does gettext require LC_MESSAGES dirs?

To translate my PHP app I use compiled in gettext module. Here is a directory tree of translations made according to docs:

locale/
cs_CZ/
LC_MESSAGES/
messages.po
messages.mo
de_DE/
LC_MESSAGES/
messages.po
messages.mo
fr_FR/
LC_MESSAGES/
messages.po
messages.mo


Question: is it possible to get rid of LC_MESSAGES catalog? Will PHP be able to find translations if I use this structure?

locale/
cs_CZ/
messages.po
messages.mo
de_DE/
messages.po
messages.mo
fr_FR/
messages.po
messages.mo


My PHP that switches translations:

<?php
setlocale(LC_ALL, 'fr_FR.UTF-8');
bindtextdomain("messages", "locale");
bind_textdomain_codeset("messages", 'UTF-8');
textdomain("messages");
?>


Thank you in advance.

Answer Source

The only feasible workaround is creating a symlink LC_MESSAGES -> . in each language subdirectory. (But this complicates PHP application installation. FTP seldomly can create symlinks.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download