一般我们都是app+dll方式,并且app和dll都可能引用同样的字符串。这个工程演示了如何架构多语言国际化的示例。
目前唯一不好的是同样的字符串需要翻译两次!shit!
架构:
/res
en-US-app.qm
en-US-dll.qm
/app
app.pro
/dll
dll.pro
strings.h
其中strings.h包含需要引用的文字:
#include <QObject>
class Strings:public QObject
{
Q_OBJECT
public:
#define STR_HELLO Strings::tr("你好")
#define STR_HELLO2 Strings::tr("好不好")
};
截屏:
代码下载: