C++ (Qt)#include <QApplication>#include <QLabel>#include <QTranslator>#include <QDir> int main( int argc, char *argv[] ){ QApplication app( argc, argv ); QTranslator myTranslator; myTranslator.load( QDir::currentPath() + "/main_ru.ts" ); app.installTranslator( &myTranslator ); QLabel label( QObject::tr( "Hello" ) ); label.show(); return app.exec();}
lupdate main.cpp -ts main_ru.ts
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE TS><TS version="2.1" language="ru_RU"><context> <name>QObject</name> <message> <location filename="main.cpp" line="9"/> <source>Hello</source> <translation>Привет</translation> </message></context></TS>
lrelease i18n.pro
C++ (Qt)myTranslator.load( QDir::currentPath() + "/main_ru.qm", "." );