C++ (Qt) QTranslator translator; translator.load("langs/lang_ru"); app.installTranslator(&translator);
C++ (Qt)int main(int argc, char *argv[]){ QApplication app(argc, argv); QApplication::setStyle("cleanlooks"); QApplication::setWindowIcon(QIcon(QPixmap(":/images/webcruiser.png"))); QTextCodec *tc = QTextCodec::codecForName("utf-8"); QTextCodec::setCodecForTr(tc); QTextCodec::setCodecForCStrings(tc); QTextCodec::setCodecForLocale(tc); QTranslator translator; translator.load("langs/lang_ru"); app.installTranslator(&translator); MainForm mainForm; return app.exec();}
void MyWiget::retranslateUi(){ label1->setText( tr( "My label" ) ); ...}
C++ (Qt)int main(int argc, char *argv[]){ ... QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); app.installTranslator(&qtTranslator); QTranslator translator; translator.load("langs/lang_ru"); app.installTranslator(&translator); MainForm mainForm; return app.exec();}
C++ (Qt)void Gui::changeEvent(QEvent* event){ if (event->type() == QEvent::LanguageChange) this->retranslateUi(); QWidget::changeEvent(event);} void Gui::retranslateUi(){ this->startButton.setText(QApplication::translate("Gui", "START")); //и так все виджеты}