PHP gettext translate in wrong language when running from shell
I have a complete PHP app, with MySQL.
All strings are using gettext, and I have 2 translations, Spanish and
English.
Original strings are written in Spanish.
it is working perfect, but, when I run a cron job, to send a report email,
it is sent using English, when it should send in spanish.
The problem isn't related to the mail code, since it works ok when I run
the cron file on the browser, plus, my email system first save it to the
DB then it sends them, and the message is already stored in English on the
DB.
So, I know my problem is the cron file is not using the correct language.
I use this code to set the language in a config file, included in ALL
files.
$language = "ES_AR.utf8"; //this is the locale name on the linux machine.
putenv("LANG=$language");
setlocale(LC_ALL, $language);
$domain = 'messages';
bindtextdomain($domain, APP_PATH . "/locale");
textdomain($domain);
As I said it works good.
I put this code at the top of the cron file, and the problem persists.
So the question is, is there something I can do to force a language when
running the cron file from shell??
Thanks!!!
No comments:
Post a Comment