Skip to content

Instantly share code, notes, and snippets.

@xenophy
Created May 4, 2011 21:33
Show Gist options
  • Save xenophy/956082 to your computer and use it in GitHub Desktop.
Save xenophy/956082 to your computer and use it in GitHub Desktop.
MacOS X translator in resource file.
#include <QtGui>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
// コーデック設定
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
// アプリケーションオブジェクト生成
QApplication app(argc, argv);
// 翻訳ファイル読み込み&インストール
QString displayLanguage = QLocale::system().name();
QTranslator *translator = new QTranslator(&app);
translator->load(":/translations/yourapp_ja.pm");
app.installTranslator(translator);
// メインウィンドウ生成
MainWindow win;
// メインウィンドウ表示
win.show();
// アプリケーション実行
return app.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment