Qt:
ADDED spanish translation ADDED switch to enabled/disable translation
This commit is contained in:
parent
091813b638
commit
ee8906b92e
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS><TS version="1.1" language="de_DE">
|
||||
<defaultcodec></defaultcodec>
|
||||
<context>
|
||||
<name>@default</name>
|
||||
<message>
|
||||
|
@ -62,124 +61,154 @@
|
|||
<context>
|
||||
<name>MainWnd</name>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="35"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="36"/>
|
||||
<source>VBA-M</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="67"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="90"/>
|
||||
<source>&File</source>
|
||||
<translation>&Datei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="71"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="95"/>
|
||||
<source>&Settings</source>
|
||||
<translation>&Einstellungen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="75"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="101"/>
|
||||
<source>&Tools</source>
|
||||
<translation>&Werkzeuge</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="78"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="105"/>
|
||||
<source>&Help</source>
|
||||
<translation>&Hilfe</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="81"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="108"/>
|
||||
<source>About &OpenGL...</source>
|
||||
<translation>Über &OpenGL...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="80"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="107"/>
|
||||
<source>About &VBA-M...</source>
|
||||
<translation>Über &VBA-M...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="82"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="109"/>
|
||||
<source>About &Qt...</source>
|
||||
<translation>Über &Qt...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="128"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="191"/>
|
||||
<source>This program is licensed under terms of the GNU General Public License.</source>
|
||||
<translation>Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="142"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="205"/>
|
||||
<source>OpenGL version 2.1 is present.</source>
|
||||
<translation>OpenGL Version 2.1 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="145"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="208"/>
|
||||
<source>OpenGL version 2.0 is present.</source>
|
||||
<translation>OpenGL Version 2.0 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="148"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="211"/>
|
||||
<source>OpenGL version 1.5 is present.</source>
|
||||
<translation>OpenGL Version 1.5 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="151"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="214"/>
|
||||
<source>OpenGL version 1.4 is present.</source>
|
||||
<translation>OpenGL Version 1.4 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="154"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="217"/>
|
||||
<source>OpenGL version 1.3 is present.</source>
|
||||
<translation>OpenGL Version 1.3 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="157"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="220"/>
|
||||
<source>OpenGL version 1.2 is present.</source>
|
||||
<translation>OpenGL Version 1.2 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="160"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="223"/>
|
||||
<source>OpenGL version 1.1 is present.</source>
|
||||
<translation>OpenGL Version 1.1 ist verfügbar.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="166"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="229"/>
|
||||
<source>OpenGL is NOT available!</source>
|
||||
<translation>OpenGL ist NICHT verfügbar!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="127"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="190"/>
|
||||
<source>About VBA-M</source>
|
||||
<translation>Über VBA-M</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="169"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="232"/>
|
||||
<source>About OpenGL</source>
|
||||
<translation>Über OpenGL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="72"/>
|
||||
<source>Select translation...</source>
|
||||
<translation>Übersetzung auswählen...</translation>
|
||||
<translation type="obsolete">Übersetzung auswählen...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="102"/>
|
||||
<source>Select translation</source>
|
||||
<translation>Übersetzung auswählen</translation>
|
||||
<translation type="obsolete">Übersetzung auswählen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="104"/>
|
||||
<source>Translation files (*.qm)</source>
|
||||
<translation>Übersetzungsdateien (*.qm)</translation>
|
||||
<translation type="obsolete">Übersetzungsdateien (*.qm)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="107"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="146"/>
|
||||
<source>.qm</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="68"/>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="91"/>
|
||||
<source>Exit</source>
|
||||
<translation>Beenden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="96"/>
|
||||
<source>Select language...</source>
|
||||
<translation>Sprache auswählen...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="129"/>
|
||||
<source>Select language</source>
|
||||
<translation>Sprache auswählen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="131"/>
|
||||
<source>Language files (*.qm)</source>
|
||||
<translation>Sprachdateien (*.qm)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="139"/>
|
||||
<source>Error!</source>
|
||||
<translation>Fehler!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="139"/>
|
||||
<source>Language file can not be loaded!</source>
|
||||
<translation>Sprachdatei kann nicht geladen werden!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="59"/>
|
||||
<source>Enable translation</source>
|
||||
<translation>Übersetzung aktivieren</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS><TS version="1.1" language="es">
|
||||
<context>
|
||||
<name>MainWnd</name>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="36"/>
|
||||
<source>VBA-M</source>
|
||||
<translation>VBA-M</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="90"/>
|
||||
<source>&File</source>
|
||||
<translation>&Archivo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="91"/>
|
||||
<source>Exit</source>
|
||||
<translation>Salir</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="95"/>
|
||||
<source>&Settings</source>
|
||||
<translation>&Ajustes</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="72"/>
|
||||
<source>Select translation...</source>
|
||||
<translation type="obsolete">Seleccione traducción...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="101"/>
|
||||
<source>&Tools</source>
|
||||
<translation>&Herramientas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="105"/>
|
||||
<source>&Help</source>
|
||||
<translation>&Ayuda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="107"/>
|
||||
<source>About &VBA-M...</source>
|
||||
<translation>Sobre &VBA-M...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="108"/>
|
||||
<source>About &OpenGL...</source>
|
||||
<translation>Sobre &OpenGL...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="109"/>
|
||||
<source>About &Qt...</source>
|
||||
<translation>Sobre &Qt...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="102"/>
|
||||
<source>Select translation</source>
|
||||
<translation type="obsolete">Seleccione traducción</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="104"/>
|
||||
<source>Translation files (*.qm)</source>
|
||||
<translation type="obsolete">Archivos de traducción (*.qm)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="146"/>
|
||||
<source>.qm</source>
|
||||
<translation>.qm</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="190"/>
|
||||
<source>About VBA-M</source>
|
||||
<translation>Sobre VBA-M</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="191"/>
|
||||
<source>This program is licensed under terms of the GNU General Public License.</source>
|
||||
<translation>Este programa se licencia bajo los términos de la Licencia Pública General GNU.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="205"/>
|
||||
<source>OpenGL version 2.1 is present.</source>
|
||||
<translation>OpenGL versión 2.1 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="208"/>
|
||||
<source>OpenGL version 2.0 is present.</source>
|
||||
<translation>OpenGL versión 2.0 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="211"/>
|
||||
<source>OpenGL version 1.5 is present.</source>
|
||||
<translation>OpenGL versión 1.5 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="214"/>
|
||||
<source>OpenGL version 1.4 is present.</source>
|
||||
<translation>OpenGL versión 1.4 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="217"/>
|
||||
<source>OpenGL version 1.3 is present.</source>
|
||||
<translation>OpenGL versión 1.3 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="220"/>
|
||||
<source>OpenGL version 1.2 is present.</source>
|
||||
<translation>OpenGL versión 1.2 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="223"/>
|
||||
<source>OpenGL version 1.1 is present.</source>
|
||||
<translation>OpenGL versión 1.1 está presente.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="229"/>
|
||||
<source>OpenGL is NOT available!</source>
|
||||
<translation>¡OpenGL no está disponible!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="232"/>
|
||||
<source>About OpenGL</source>
|
||||
<translation>Sobre OpenGL</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="96"/>
|
||||
<source>Select language...</source>
|
||||
<translation>Seleccione traducción...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="129"/>
|
||||
<source>Select language</source>
|
||||
<translation>Seleccione traducción</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="131"/>
|
||||
<source>Language files (*.qm)</source>
|
||||
<translation>Archivos de traducción (*.qm)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="139"/>
|
||||
<source>Error!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="139"/>
|
||||
<source>Language file can not be loaded!</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/qt/MainWnd.cpp" line="59"/>
|
||||
<source>Enable translation</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
|
@ -15,3 +15,4 @@ HEADERS += ../../src/qt/glwidget.h
|
|||
SOURCES += ../../src/qt/glwidget.cpp
|
||||
|
||||
TRANSLATIONS += ../../lang/german.ts
|
||||
TRANSLATIONS += ../../lang/spanish.ts
|
||||
|
|
|
@ -106,6 +106,10 @@
|
|||
RelativePath="..\..\lang\german.ts"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\lang\spanish.ts"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Other"
|
||||
|
|
|
@ -27,13 +27,15 @@ MainWnd::MainWnd( QWidget *parent, QApplication *app, QTranslator **trans )
|
|||
fileMenu( 0 ),
|
||||
settingsMenu( 0 ),
|
||||
toolsMenu( 0 ),
|
||||
helpMenu( 0 )
|
||||
helpMenu( 0 ),
|
||||
enableTranslationAct( 0 )
|
||||
{
|
||||
createDisplay();
|
||||
|
||||
setMinimumSize( 320, 240 );
|
||||
setWindowTitle( tr( "VBA-M" ) );
|
||||
|
||||
createActions();
|
||||
createMenus();
|
||||
}
|
||||
|
||||
|
@ -41,6 +43,26 @@ MainWnd::~MainWnd()
|
|||
{
|
||||
}
|
||||
|
||||
void MainWnd::createActions()
|
||||
{
|
||||
bool enabled, checked;
|
||||
|
||||
if( enableTranslationAct != 0 ) {
|
||||
enabled = enableTranslationAct->isEnabled(); // memorize state
|
||||
checked = enableTranslationAct->isChecked();
|
||||
delete enableTranslationAct;
|
||||
enableTranslationAct = 0;
|
||||
} else {
|
||||
enabled = false;
|
||||
checked = false;
|
||||
}
|
||||
enableTranslationAct = new QAction( tr( "Enable translation" ), this );
|
||||
enableTranslationAct->setEnabled( enabled );
|
||||
enableTranslationAct->setCheckable( true );
|
||||
enableTranslationAct->setChecked( checked );
|
||||
connect( enableTranslationAct, SIGNAL( toggled( bool ) ), this, SLOT( enableTranslation( bool ) ) );
|
||||
}
|
||||
|
||||
void MainWnd::createMenus()
|
||||
{
|
||||
if( fileMenu ) {
|
||||
|
@ -63,17 +85,22 @@ void MainWnd::createMenus()
|
|||
helpMenu = 0;
|
||||
}
|
||||
|
||||
|
||||
// File menu
|
||||
fileMenu = menuBar()->addMenu( tr( "&File" ) );
|
||||
fileMenu->addAction( tr( "Exit" ), this, SLOT( close() ) );
|
||||
|
||||
|
||||
// Settings menu
|
||||
settingsMenu = menuBar()->addMenu( tr( "&Settings" ) );
|
||||
settingsMenu->addAction( tr( "Select translation..." ), this, SLOT( selectTranslation() ) );
|
||||
settingsMenu->addAction( tr( "Select language..." ), this, SLOT( selectLanguage() ) );
|
||||
settingsMenu->addAction( enableTranslationAct );
|
||||
|
||||
|
||||
// Tools menu
|
||||
toolsMenu = menuBar()->addMenu( tr( "&Tools" ) );
|
||||
|
||||
|
||||
// Help menu
|
||||
helpMenu = menuBar()->addMenu( tr( "&Help" ) );
|
||||
|
||||
|
@ -95,31 +122,67 @@ bool MainWnd::createDisplay()
|
|||
return false;
|
||||
}
|
||||
|
||||
void MainWnd::selectTranslation()
|
||||
bool MainWnd::selectLanguage()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr( "Select translation" ),
|
||||
tr( "Select language" ),
|
||||
"lang",
|
||||
tr( "Translation files (*.qm)" ) );
|
||||
tr( "Language files (*.qm)" ) );
|
||||
|
||||
if( file.isNull() ) return;
|
||||
if( !file.endsWith( tr( ".qm" ), Qt::CaseInsensitive ) ) return;
|
||||
if( file.isNull() ) return false;
|
||||
|
||||
// load translation
|
||||
bool ret = loadTranslation( file );
|
||||
ret &= enableTranslation( true );
|
||||
|
||||
if( ret == false ) {
|
||||
QMessageBox::critical( this, tr( "Error!" ), tr( "Language file can not be loaded!" ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MainWnd::loadTranslation( QString file )
|
||||
{
|
||||
if( !file.endsWith( tr( ".qm" ), Qt::CaseInsensitive ) ) return false;
|
||||
|
||||
// remove current translation
|
||||
enableTranslation( false );
|
||||
if( *translator != 0 ) {
|
||||
theApp->removeTranslator( *translator );
|
||||
delete *translator;
|
||||
*translator = 0;
|
||||
}
|
||||
|
||||
file.chop( 3 ); // remove file extension ".qm"
|
||||
|
||||
// load new translation
|
||||
*translator = new QTranslator();
|
||||
(*translator)->load( file );
|
||||
theApp->installTranslator( *translator );
|
||||
bool ret = (*translator)->load( file );
|
||||
enableTranslationAct->setEnabled( ret );
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool MainWnd::enableTranslation( bool enable )
|
||||
{
|
||||
if( enable ) {
|
||||
if( *translator != 0 ) {
|
||||
theApp->installTranslator( *translator );
|
||||
enableTranslationAct->setChecked( true );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if( *translator != 0 ) {
|
||||
theApp->removeTranslator( *translator );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// apply translation
|
||||
createMenus();
|
||||
// the user might have to restart the application to apply changes completely
|
||||
createActions();
|
||||
createMenus();
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWnd::showAbout()
|
||||
|
|
|
@ -29,23 +29,28 @@ public:
|
|||
MainWnd::MainWnd( QWidget *parent = 0, QApplication *app = 0, QTranslator **trans = 0 );
|
||||
MainWnd::~MainWnd();
|
||||
|
||||
public slots:
|
||||
bool loadTranslation( QString file );
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
bool createDisplay();
|
||||
|
||||
private slots:
|
||||
void selectTranslation();
|
||||
void showAbout();
|
||||
void showAboutOpenGL();
|
||||
void showAboutQt();
|
||||
|
||||
private:
|
||||
QApplication *theApp;
|
||||
QTranslator **translator;
|
||||
QMenu *fileMenu;
|
||||
QMenu *settingsMenu;
|
||||
QAction *enableTranslationAct;
|
||||
QMenu *toolsMenu;
|
||||
QMenu *helpMenu;
|
||||
|
||||
private slots:
|
||||
bool selectLanguage();
|
||||
bool enableTranslation( bool enable );
|
||||
void showAbout();
|
||||
void showAboutOpenGL();
|
||||
void showAboutQt();
|
||||
};
|
||||
|
||||
#endif // #ifndef MAINWND_H
|
||||
|
|
Loading…
Reference in New Issue