GTK 中多国语言
来源:互联网 发布:淘宝上在哪里投诉快递 编辑:程序博客网 时间:2024/04/29 10:42
1. In source code
#include<gtk/gtk.h>
#include<libintl.h>
#define _(STRING) gettext(STRING)
#define PACKAGE "record_zh" //will build record_zh.mo
#define LOCALEDIR "./mo"
int main(int argc, char *argv[])
{
...
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
bind_textdomain_codeset(PACKAGE, "UTF-8");
gtk_init(&argc, &argv);
...
}
2. Build po file
#xgettext -k_ -o ui_pref.pot *.c *.h
#cp ui_pref.pot zh_CN.po
#vim zh_CN.po
change the zh_CN.po file head "charset=CHARSET" to "charset=UTF-8"
Change capital string part in head if you need.
translate msgid and write then in msgstr
eg, in zh_CN.po:
...
#callback.c:67
msgid "Delete record failure/n"
msgstr "删除纪录失败/n"
...
3. Make .mo file
#msgfmt -o record_zh.mo zh_CN.po
4. Copy .mo to right directly
#mkdir -p mo/zh_CN/LC_MESSAGES
#cp record_zh.mo mo/zh_CN/LC_MESSAGES
You also can copy .mo to /usr/share/locale/zh_CN/LC_MESSAGES/
then your main file need remove lines
#define LOCALEDIR "./mo"
bindtextdomain(PACKAGE, LOCALEDIR);
5. Do test
#export LANG=zh_CN.UTF-8
run your program
When you run your program, if show below information
Gtk-WARNING **: Locale not supported by c library
Using the fallback 'C' locale
You can use "locale -a" check the language
#vim /var/lib/locales/supported.d/local
Add "zh_CN.UTF-8 UTF-8"
The other support language you can see /usr/share/i18n/SUPPORTED
#sudo locale-gen
Then you can see a zh_CN.utf8 in /usr/lib/locale/
- GTK 中多国语言
- GTK 中多国语言
- WinCE中支持多国语言切换
- WinForm中多国语言的实现
- WinCE中支持多国语言切换
- WinForm中多国语言的实现
- WinCE中支持多国语言切换
- xcode4中添加多国语言
- WinForm中多国语言的实现
- 多国语言
- 多国语言解决方案
- 多国语言支持
- 多国语言
- c# 多国语言
- 移植多国语言
- MTK--多国语言
- 多国语言实现
- 支持多国语言
- C# 画4位或8位图(将图片压缩成4位或8位)
- 前言 数组与指针的艺术
- 第一章:数组与指针概念剖析
- ASP.NET - Label Web 服务器控件概述
- 无线LAN简介
- GTK 中多国语言
- 活了yuyilin
- XML 有什么用
- C++ ,dll 接口程序设计心得
- 2009-11-23
- 对Google chrome OS 有点失望
- 雷军:为什么马云马化腾创业那么容易成功 自己却需要煎熬数年
- ADA_CDMATool 网优工具
- linux锐捷上网-mentohust