0

Does anyone happen to know why a call to setlocale would fail for a reason other than the locale package not existing. The following code:

$language = 'fr_CA.utf8';
//putenv("LANG=" . $language); 

var_dump(setlocale(LC_ALL, $language));

// Set the text domain as "messages"
$domain = "messages";
$result = bindtextdomain($domain, ROOT_DIR . "../locale/");

bind_textdomain_codeset($domain, 'UTF-8');

$result = textdomain($domain);

echo _("IAMSOMETEXT");
echo $result;die;

outputs bool(false) from the var_dump. We are running the site in Vagrant, however I ran locale -a on the VM, and fr_CA.utf8 was indeed in the output. I have tried other variations that were listed such as simply fr_CA.

Setting the locale to en_US.utf8 works perfectly however. POSIX does seem to work as well. Has anyone ran into this issue? We are running Ubuntu 12.04 on the VM.

Joseph Pla
  • 1,600
  • 1
  • 10
  • 21
  • `fa_CA.utf8` doesn't work for me either. `fra_can` works. `fra_can.utf8` doesn't. Two letter language codes don't seem to work for me: `en_us` vs `eng_usa`. – Halcyon Nov 05 '14 at 17:04
  • are those available in your locale -a outputs? – Joseph Pla Nov 05 '14 at 17:08
  • If you type "LC_ENV=fr_CA.utf8 date" on the command line, is the date printed in French? How about "echo exec('locale -a');" in PHP? Is it a plain Ubuntu 12.04 installation? – bgm Nov 14 '14 at 14:15

1 Answers1

0

Try using Session.LCID, which should have read/write access. It's a number, like 1034

den232
  • 682
  • 6
  • 14