PDA

View Full Version : language translation



thomasjoy
11th May 2007, 08:45
hi guys
i m working on qt4.2 on Mac OS X Platform
can anyone tell me how can convert my .app to another languages like japnese ,spanish,italino etc.

thanks in advance

jpn
11th May 2007, 08:51
Hi

Please, start with reading Internationalization with Qt (http://doc.trolltech.com/4.2/i18n.html).

patrik08
11th May 2007, 09:25
Hi
Please, start with reading Internationalization with Qt (http://doc.trolltech.com/4.2/i18n.html).


Correct ... next if you have the language file tell main.cpp to find its...



/* mac osx bundle path resolver */
static inline QString UserLanguage()
{
QString languser,languagesistem,langqt;
QLocale loci = QLocale::system();
languser = getenv("LANG");
languser = languser.toLower();
languagesistem = loci.name();
languagesistem = languagesistem.toLower();
languagesistem = languagesistem.left(2);
/* Window XP Prof MUI Multiuser Multilanguage == stay only "c" language && user setting setenv !!! */
/* if not XP MUI BUG! return ... */
if (languagesistem == "c") {
if (languser.size() > 2 && languser.contains("_")) {
languagesistem = languser.left(2); /* grep from LANG if QLocale having C*/
}
}
return languagesistem;
/* return de or en,it,fr .. first two from language*/
}

int main(int argc, char *argv[]) {
QApplication a( argc, argv );

/* qsetting */
QCoreApplication::setOrganizationName(_ORGANIZATIO N_NAME_);
QCoreApplication::setOrganizationDomain(_PROGRAM_N AME_DOMAINE_);
QCoreApplication::setApplicationName(_PROGRAM_NAME _);

/* bundle mac paths */
#if defined Q_WS_MAC
QStringList path;
path.append(QApplication::applicationDirPath());
QDir dir(QApplication::applicationDirPath());
dir.cdUp();
path.append(dir.absolutePath());
dir.cd("plugins");
path.append(dir.absolutePath());
dir.cdUp();
path.append(dir.absolutePath());
QApplication::setLibraryPaths(path);
QDir::setCurrent(dir.absolutePath()); /* here down -> Frameworks locale plugin */
#endif

#if defined Q_WS_MAC
localedirfile = QString("%1/locale/edit_%2.qm").arg(QDir::currentPath()).arg(UserLanguage());
#endif
#if defined Q_WS_WIN
localedirfile = QString("%1/locale/edit_%2.qm").arg(QCoreApplication::applicationDirPath()).arg( UserLanguage());
#endif
#if defined Q_WS_X11
localedirfile = QString("%1/locale/edit_%2.qm").arg(WORK_CACHEDIR).arg(UserLanguage()); /* /home/user/.appname/ */
#endif

QTranslator translator;
translator.load(localedirfile);
a.installTranslator(&translator);

/* next class main to start ....*/