TRANSLATIONS = locale/app_en.ts locale/app_de.ts locale/app_it.ts locale/app_en.ts locale/app_fr.ts locale/app_pt.ts
qmake compiliert sie...
im resourse datei sind alle drinnen.... text & compiliert..
<qresource prefix="/locale" >
<file>locale/app_de.qm</file>
<file>locale/app_de.ts</file>
<file>locale/app_en.qm</file>
<file>locale/app_en.ts</file>
<file>locale/app_fr.qm</file>
<file>locale/app_fr.ts</file>
<file>locale/app_it.qm</file>
<file>locale/app_it.ts</file>
<file>locale/app_pt.qm</file>
<file>locale/app_pt.ts</file>
</qresource>
in der main() lade ich die funktion vor sie vor QApplication...
doch QLocale::system().name() gibt immer = C .... ist das normal?
Code: Alles auswählen
QString transdir=QString::fromUtf8(":/locale/locale/app_"); /* dir prefix on resource */
QString find = QLocale::system().name().left(QLocale::system().name().indexOf("_"))+".qm"; /* en.qm */
QApplication a( argc, argv );
Config cf; /* class Config */
QString filecompletefullpath = transdir + find;
QFileInfo fi( filecompletefullpath );
if ( !fi.exists() ) {
QMessageBox::warning( 0, "File error",
QString(" Cannot find "+filecompletefullpath+" translation file for locale language: "+QLocale::system().name().left(QLocale::system().name().indexOf("_"))+
"\n Contact the programm owner ... and you can traslate the language=" + QLocale::system().name() + "." )); //////
return 0;
}
QTranslator translator;
translator.load(filecompletefullpath);
a.installTranslator(&translator);