qt translation and discussion of internationalization.

This time has been in the international hate qt, previously also contacted international, but the feeling is not so deep, because this is a project to do an international version of the code which can not appear in Chinese, so we He translated a bit. 4.8.6 qt using a 64-bit, IDE (Integrated Development Environment) is used vs2010.

I put my process operations here for everyone to say again, as I do, then certainly no problem, in fact, need two files, one is ts file, a file is qm.

The first step involves adding a paragraph in the pro file.

 

TRANSLATIONS    +=  offlinedataquery_zh.ts

In fact, the file name can go given, I am here it is because the project needs is the name given offlinedataquery_zh, zh is a Chinese translation of this, if you need other languages ​​can also define other, such as Japanese jp can be defined.

 

The second step is to find qt bin directory, you can use cmd.

 

Then execute

lupdate offlinedataquery.pro

Here file or to pinpoint the path of the job.

Ts here will generate a file in the root directory.

Then perform

lrelease offlinedataquery_zh.ts

This time it generated a qm file, this is what we need to load in the code file

    QTranslator* Translator = new QTranslator;
    QString tmp_gcdir = QObject::tr(getenv("GCDIR"));
    QString tmp_trans = tmp_gcdir + "/translations/offlinedataquery_zh.qm";
    Translator->load(tmp_trans);
    app.installTranslator(Translator);

This can translate success.

 

But I have a question here, there is a problem, ts Chinese seemed not every tr () can be translated, so I can only add themselves.

 

    <message utf8="true">
        <location filename="seltimedlg.ui" line="47"/>
        <source>WAMS substation</source>
        <translation>WAMS子站</translation>
    </message>

 

In accordance with this format to add on it, and finally perform again lrelease offlinedataquery_zh.ts, generate qm file again on it.

The whole process is such that you want to help, in fact it is not difficult, is to be patient on it! ! !

 

Guess you like

Origin www.cnblogs.com/joorey/p/11804779.html