【发布时间】:2011-07-22 21:54:12
【问题描述】:
向 C++ 程序添加多语言支持的最佳方法是什么?
如果可能,应该从包含键值对(§WelcomeMessage§ "Hello %s!")之类的纯文本文件中读取语言。
我想到了添加一个返回已加载语言文件字符串的本地化字符串(键)函数。有没有更好或更有效的方法?
//half-pseudo code
//somewhere load the language key value pairs into langfile[]
string localizedString(key)
{
//do something else here with the string like parsing placeholders
return langfile[key];
}
cout << localizedString(§WelcomeMessage§);
【问题讨论】:
-
ICU library 就是为此而设计的。
标签: c++ localization translation multilingual