Seite 1 von 1
Sprache zur laufzeit ändern [gelöst]
Verfasst: 31. März 2006 12:28
von archer
Hallo,
kennt sich jemand mit dem QTranslator aus?
Ich möchte die Sprache meines Programms ändern.
Dieses möchte ich jedoch tun ohne das Programm zu beenden und neu zu starten.
Wie bringe ich die Oberfläche (meine ui-files) dazu eine andere Sprachdatei zu laden?
mfg archer
Verfasst: 31. März 2006 13:42
von macman
Hatten wir erst kürzlich hier, such im Forum.
Verfasst: 3. April 2006 11:37
von patrik08
im offizielle qt3 ist ein beisbiel!
oder mit subversion
svn co
http://ciz.ch/svnciz/dialog_qt/qt4_a/qt ... _i18n_QT3/
ordnerx
die linguistig file werden hineincompliliert...
oder appTranslator.load(find,transdir); ///// file , path resourcefile //////
reset doku und neues file laden...
Code: Alles auswählen
#if defined( Q_WS_X11 )
QString transdir=PREFIX"/share/qt4ds_x11/locale/";
#endif
#if defined( Q_WS_MACX )
QString transdir="/Applications/qt4ds_mac.app/Contents/Resources/locale/";
#endif
#if defined(Q_WS_WIN)
QString transdir=QCoreApplication::applicationDirPath()+"/locale/";
#endif
/* other way install all locale to QString workdir = QString( "%1/.%2/" ).arg( QDir::homePath(), QUIKCONFIG ); */
/* best way build relase to put inside / CONFIG += qt warn_on release */
QString find = "qt4ds_" + QLocale::system().name().left(QLocale::system().name().indexOf("_"))+".qm";
QString fullpath = transdir + find;
QFileInfo fi( fullpath );
if ( !fi.exists() ) {
QMessageBox::warning( 0, "File error",
QString(" Cannot find translation file "+find+" for locale language: "+QLocale::system().name().left(QLocale::system().name().indexOf("_"))+
"\n Fullpath file is : "+fullpath+"\n insert file \""+find+"\" on subdir \""+transdir+"\" and all running ok!" )); //////
return 0;
}
/* debug_debug section */
//// discovery what file to load ! ////////
///////file_put_contents("nameformat_name.dat",find);
//// discovery what file to load ! ////////
appTranslator.load(find,transdir); ///// file , path resourcefile //////
app.installTranslator(&appTranslator);
Verfasst: 3. April 2006 11:57
von archer
Wenn ich das Baispiel richtig verstehe, wird der Translator gelöscht un neu angelegt.
Das habe ich auch getan.
Aber mein Problem ist folgendes:
- ich habe mein MainForm.
- nun erzeuge ich zu Laufzeit andere Widgets (Formulare) mit new.
- In diesen willich nun die Sprache ändern, ohne diese zu löschen und neu
zu erzeugen.
So wie ich das sehe werde ich mir wohl meine eigene Methode schreiben müssen, die die Texte "per Hand" setzt. Ähnlich dem changeLanguage() event.
Ich haate gehofft, ich kann einen neuen Translator laden und der gui sagen - alle texte neu einlesen.
Verfasst: 4. April 2006 19:12
von pasnox
Hi,
Please don't distribute modified source of qt4ds monkey with the name of mine, because your qt4ds-monkey modified source is not the original, please considere rennaming it to what you want, or ask me to join the project on sourceforge if you want to add your modification.
P@sNox
Verfasst: 8. April 2006 13:54
von patrik08
this code is only sample ... to learn qt
your original code reside on
http://sourceforge.net/projects/qt4ds-monkey
Verfasst: 11. April 2006 12:11
von pasnox
Hi,
Ok for the lessons :p
I see your have post some unreadable french note on my french forum.
U can repost it in the uk forum please ?
UK Forum:
http://sourceforge.net/forum/?group_id=163493
Nox,