简体   繁体   English

Windows路径中的PHP Gettext

[英]php Gettext in windows path

Hi i am trying to use gettext in windows. 嗨,我正在尝试在Windows中使用gettext。 This code runs fine on linux but in windows doesnt work. 此代码在linux上运行良好,但在Windows中不起作用。 the problem is that it doesnt find the path to locale folder. 问题是它找不到语言环境文件夹的路径。 any advice? 有什么建议吗?

<?php
// I18N support information here
$language = 'pt_BR';
putenv("LANG=$language"); 
setlocale(LC_ALL, $language);

// Set the text domain as 'messages'
$domain = 'messages';
bindtextdomain($domain, './locale'); 
textdomain($domain);

echo gettext("A string to be translated would go here");

?> ?>

Your code worked without no problem on my Windows box (Windows 7 professional) if I place the code as, 如果我将代码放在以下位置,则您的代码可以在Windows框(Windows 7专业版)上正常运行,

 c:\temp\test.php

and the resource file as 和资源文件为

 c:\temp\locales\pt_BR\LC_MESSAGES\messages.mo

I made the message.mo file by making messages.po in the same directory, then edit the file on Poedit, add a translation of "A string to be translated would go here"(I do not know Portuguese so it was dummy text), save (as .mo). 我通过在同一目录中创建messages.po来创建message.mo文件,然后在Poedit上编辑该文件,并添加翻译“将要翻译的字符串放在此处”(我不知道葡萄牙语,所以它是虚拟文本) ,另存为(.mo)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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