gettext-0.10.40版本
嵌入式设备上操作
/usr/local #export LC_MESSAGES="zh_CN.GB2312"
/usr/local # export TEXTDOMAINDIR="/usr/local/share/locale/"
/usr/local # ./gettext -s -d dvr 'NAS'
返回NAS,按照msgid查询,无法返回对应的msgstr。
究其原因:在设置LC_MESSAGES="zh_CN.GB2312"或LC_MESSAGES="zh_CN"后
setlocale函数没有正确返回设置环境变量指示语言的值。
zh_CN.GB2312:对应"/usr/local/share/locale/zh_CN.GB2312/LC_MESSAGES/" mo搜索资源路径。
zh_CN:对应"/usr/local/share/locale/zh_CN/LC_MESSAGES/" mo的搜索路径。
修改内容:
gettext-0.10.40\intl\dcigettext.c
L:1170-1173, 1189行
修改表现效果如下:
gettext-0.19.8.1版本
utf-8 字符集支持修改内容如下:
Index: gettext-runtime/intl/localcharset.c
===================================================================
--- gettext-runtime/intl/localcharset.c (版本 33857)
+++ gettext-runtime/intl/localcharset.c (工作副本)
@@ -397,7 +397,7 @@
#if !(defined WINDOWS_NATIVE || defined OS2)
-# if HAVE_LANGINFO_CODESET
+# if 0//HAVE_LANGINFO_CODESET //bstar added
/* Most systems support nl_langinfo (CODESET) nowadays. */
codeset = nl_langinfo (CODESET);
Index: gettext-runtime/intl/localename.c
===================================================================
--- gettext-runtime/intl/localename.c (版本 33857)
+++ gettext-runtime/intl/localename.c (工作副本)
@@ -2788,6 +2788,7 @@
const char *
gl_locale_name_posix (int category, const char *categoryname)
{
+ return gl_locale_name_environ (category, categoryname); //bstar added
/* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
On some systems this can be done by the 'setlocale' function itself. */
#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL