简体   繁体   中英

PHP gettext translation is not working

I need to translate my site to Tamil. This is my code:

$locale = "ta_IN";

putenv("LANG=".$locale);
setlocale(LC_ALL, $locale);

$domain = "ta_IN";
echo bindtextdomain($domain, "Locale");
bind_textdomain_codeset($domain, 'UTF-8');

textdomain($domain);

echo  _("Username");

And I have create .mo and .po files for the word Username and which is in the /var/www/tamil/Locale/ta_IN/LC_MESSAGES/ta_IN.mo and ta_IN.po , but it is not translating my site.

I have these questions and their accepted answers, but the solutions did not work for me:

如果要在控制台(PHP-CLI)上而不是在Web服务器上测试gettext,则也必须重置LANGUAGE环境变量。

putenv("LANGUAGE=");

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