douchan6512
2009-09-20 01:33
浏览 82
已采纳

如何在PHP中使用gettext加载语言?

I have created a language file in poedit for the use of the PHP gettext function, now on the page I am trying to test it on, I cannot get it to find/load the .po or .mo file I created, does anyone see what I am doing wrong?

$locale = "en_US";
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
bindtextdomain("default", "/includes/locale");
textdomain("default");

//my .po ad .mo file is located here /includes/locale/en/default.mo

Even though I am trying to load the default english lang file, I have changed some text in the file to make sure it is reading from a language file and currently it is only showing the default text and not doing a translation, I think I have the wrong path possibly

图片转代码服务由CSDN问答提供 功能建议

我在poedit中创建了一个语言文件,用于使用PHP gettext函数,现在我正在尝试的页面上 要测试它,我无法找到/加载我创建的.po或.mo文件,是否有人看到我做错了什么?</ p>

  $ locale =“  en_US“; 
putenv(”LC_ALL = $ locale“); 
setlocale(LC_ALL,$ locale); 
bindtextdomain(”default“,”/ includes / locale“); 
textdomain(”default“); 
 
  //我的.po广告.mo文件位于/includes/locale/en/default.mo
nn

即使我正在尝试加载默认的英语lang 文件,我已经更改了文件中的一些文本,以确保它是从一个语言文件读取,目前它只显示默认文本而不进行翻译,我想我的路径可能错误</ p> < / DIV>

2条回答 默认 最新

相关推荐 更多相似问题