关于gettext的代码问题
时间:2008-07-10
来源:互联网
locale下 zh_CN/LC_MESSAGES/test.po test.mo 都在
但是始终不出现中文,感觉是找不到mo 和po文件
bindtextdomain 尝试用 locale ../locale 也都一样。
环境 ubuntu
php 代码如下
<?php
define('PACKAGE','test');
putenv('LANG=zh_CN');
setlocale(LC_ALL,'zh_CN');
bindtextdomain(PACKAGE,'/home/hatoyu/www/locale');
textdomain(PACKAGE);
echo gettext("ok");
echo gettext("ok2");
echo gettext("hello world");
echo gettext("who are u");
?>
po代码如下:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: macaucs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-07-10 11:48+0800\n"
"PO-Revision-Date: 2008-07-10 11:52+0800\n"
"Last-Translator: Hato Yu <[email protected]>\n"
"Language-Team: hatoyu <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: Chinese\n"
"X-Poedit-Country: CHINA\n"
"X-Poedit-SourceCharset: utf-8\n"
#: /home/hatoyu/www/test.php:12
msgid "ok"
msgstr "好了"
#: /home/hatoyu/www/test.php:13
msgid "ok2"
msgstr "更好了"
#: /home/hatoyu/www/test.php:15
msgid "hello world"
msgstr "你好世界"
#: /home/hatoyu/www/test.php:16
msgid "who are u"
msgstr "你是谁"
但是始终不出现中文,感觉是找不到mo 和po文件
bindtextdomain 尝试用 locale ../locale 也都一样。
环境 ubuntu
php 代码如下
<?php
define('PACKAGE','test');
putenv('LANG=zh_CN');
setlocale(LC_ALL,'zh_CN');
bindtextdomain(PACKAGE,'/home/hatoyu/www/locale');
textdomain(PACKAGE);
echo gettext("ok");
echo gettext("ok2");
echo gettext("hello world");
echo gettext("who are u");
?>
po代码如下:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: macaucs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2008-07-10 11:48+0800\n"
"PO-Revision-Date: 2008-07-10 11:52+0800\n"
"Last-Translator: Hato Yu <[email protected]>\n"
"Language-Team: hatoyu <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: Chinese\n"
"X-Poedit-Country: CHINA\n"
"X-Poedit-SourceCharset: utf-8\n"
#: /home/hatoyu/www/test.php:12
msgid "ok"
msgstr "好了"
#: /home/hatoyu/www/test.php:13
msgid "ok2"
msgstr "更好了"
#: /home/hatoyu/www/test.php:15
msgid "hello world"
msgstr "你好世界"
#: /home/hatoyu/www/test.php:16
msgid "who are u"
msgstr "你是谁"
作者: hatoyu 发布时间: 2008-07-10
解决问题还是要靠自己
setlocale(LC_ALL,'zh_CN.UTF-8');
后面加了utf-8 就解决了
我的os是 ubuntu 8.04 中文,估计和这个有关系
setlocale(LC_ALL,'zh_CN.UTF-8');
后面加了utf-8 就解决了
我的os是 ubuntu 8.04 中文,估计和这个有关系
作者: hatoyu 发布时间: 2008-07-10
还是很聪明的读者

作者: phpcast 发布时间: 2008-07-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28