Originally Posted by
jpn
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;
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[]) {
/* qsetting */
/* bundle mac paths */
#if defined Q_WS_MAC
dir.cdUp();
path.append(dir.absolutePath());
dir.cd("plugins");
path.append(dir.absolutePath());
dir.cdUp();
path.append(dir.absolutePath());
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
#endif
#if defined Q_WS_X11
localedirfile
= QString("%1/locale/edit_%2.qm").
arg(WORK_CACHEDIR
).
arg(UserLanguage
());
/* /home/user/.appname/ */#endif
translator.load(localedirfile);
a.installTranslator(&translator);
/* next class main to start ....*/
/* 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(_ORGANIZATION_NAME_);
QCoreApplication::setOrganizationDomain(_PROGRAM_NAME_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 ....*/
To copy to clipboard, switch view to plain text mode
Bookmarks