简体   繁体   中英

i18n not working via php-fpm in debian

I have a strange issue here. Here is the code:

 cat ./test.php
<?php

setlocale(LC_ALL,"");
//setlocale(LC_MESSAGES,'ru');
//setlocale(LC_CTYPE,'ru');
putenv("LANG=ru");
putenv("LANGUAGE=ru");

$domain = 'messages';
bindtextdomain($domain, "./locale");
textdomain($domain);
//var_dump($r);
//exit;

echo gettext("Welcome to My PHP Application");
print "\n";
echo gettext("ololo");

Here are localization files:

find ./locale/
./locale/
./locale/ru
./locale/ru/LC_MESSAGES
./locale/ru/LC_MESSAGES/messages.mo
./locale/ru/LC_MESSAGES/messages.po
./locale/en
./locale/en/LC_MESSAGES
./locale/en/LC_MESSAGES/messages.mo
./locale/en/LC_MESSAGES/messages.po

When I'm executing the script via CLI, everything's okay:

php ./test.php
Добро пожаловать!
452231

But when I'm calling it from the web, I'm getting only:

Welcome to My PHP Application
ololo

What am I missing? I'm using Debian 8.6, nginx, php-fpm 5.6.29. Gettext and Intl modules are enabled in CLI and FPM configurations both.

Thanks!

解决方案由作者完成:默认情况下,php-fpm.conf clear_env参数设置为Yes在添加此池配置中指定的env vars之前,通过清除工作线程中的环境,防止任意环境变量到达FPM工作进程设置为No请参阅手册http://php.net/manual/en/install.fpm.configuration.php#clear-env

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM