ADDED spanish translation
ADDED switch to enabled/disable translation
This commit is contained in:
spacy51 2008-02-10 12:35:36 +00:00
parent 091813b638
commit ee8906b92e
6 changed files with 302 additions and 44 deletions

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1" language="de_DE"> <!DOCTYPE TS><TS version="1.1" language="de_DE">
<defaultcodec></defaultcodec>
<context> <context>
<name>@default</name> <name>@default</name>
<message> <message>
@ -62,124 +61,154 @@
<context> <context>
<name>MainWnd</name> <name>MainWnd</name>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="35"/> <location filename="../src/qt/MainWnd.cpp" line="36"/>
<source>VBA-M</source> <source>VBA-M</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="67"/> <location filename="../src/qt/MainWnd.cpp" line="90"/>
<source>&amp;File</source> <source>&amp;File</source>
<translation>&amp;Datei</translation> <translation>&amp;Datei</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="71"/> <location filename="../src/qt/MainWnd.cpp" line="95"/>
<source>&amp;Settings</source> <source>&amp;Settings</source>
<translation>&amp;Einstellungen</translation> <translation>&amp;Einstellungen</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="75"/> <location filename="../src/qt/MainWnd.cpp" line="101"/>
<source>&amp;Tools</source> <source>&amp;Tools</source>
<translation>&amp;Werkzeuge</translation> <translation>&amp;Werkzeuge</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="78"/> <location filename="../src/qt/MainWnd.cpp" line="105"/>
<source>&amp;Help</source> <source>&amp;Help</source>
<translation>&amp;Hilfe</translation> <translation>&amp;Hilfe</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="81"/> <location filename="../src/qt/MainWnd.cpp" line="108"/>
<source>About &amp;OpenGL...</source> <source>About &amp;OpenGL...</source>
<translation>Über &amp;OpenGL...</translation> <translation>Über &amp;OpenGL...</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="80"/> <location filename="../src/qt/MainWnd.cpp" line="107"/>
<source>About &amp;VBA-M...</source> <source>About &amp;VBA-M...</source>
<translation>Über &amp;VBA-M...</translation> <translation>Über &amp;VBA-M...</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="82"/> <location filename="../src/qt/MainWnd.cpp" line="109"/>
<source>About &amp;Qt...</source> <source>About &amp;Qt...</source>
<translation>Über &amp;Qt...</translation> <translation>Über &amp;Qt...</translation>
</message> </message>
<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> <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> <translation>Dieses Programm ist unter den Bedingungen der GNU General Public License lizenziert.</translation>
</message> </message>
<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> <source>OpenGL version 2.1 is present.</source>
<translation>OpenGL Version 2.1 ist verfügbar.</translation> <translation>OpenGL Version 2.1 ist verfügbar.</translation>
</message> </message>
<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> <source>OpenGL version 2.0 is present.</source>
<translation>OpenGL Version 2.0 ist verfügbar.</translation> <translation>OpenGL Version 2.0 ist verfügbar.</translation>
</message> </message>
<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> <source>OpenGL version 1.5 is present.</source>
<translation>OpenGL Version 1.5 ist verfügbar.</translation> <translation>OpenGL Version 1.5 ist verfügbar.</translation>
</message> </message>
<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> <source>OpenGL version 1.4 is present.</source>
<translation>OpenGL Version 1.4 ist verfügbar.</translation> <translation>OpenGL Version 1.4 ist verfügbar.</translation>
</message> </message>
<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> <source>OpenGL version 1.3 is present.</source>
<translation>OpenGL Version 1.3 ist verfügbar.</translation> <translation>OpenGL Version 1.3 ist verfügbar.</translation>
</message> </message>
<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> <source>OpenGL version 1.2 is present.</source>
<translation>OpenGL Version 1.2 ist verfügbar.</translation> <translation>OpenGL Version 1.2 ist verfügbar.</translation>
</message> </message>
<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> <source>OpenGL version 1.1 is present.</source>
<translation>OpenGL Version 1.1 ist verfügbar.</translation> <translation>OpenGL Version 1.1 ist verfügbar.</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="166"/> <location filename="../src/qt/MainWnd.cpp" line="229"/>
<source>OpenGL is NOT available!</source> <source>OpenGL is NOT available!</source>
<translation>OpenGL ist NICHT verfügbar!</translation> <translation>OpenGL ist NICHT verfügbar!</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="127"/> <location filename="../src/qt/MainWnd.cpp" line="190"/>
<source>About VBA-M</source> <source>About VBA-M</source>
<translation>Über VBA-M</translation> <translation>Über VBA-M</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="169"/> <location filename="../src/qt/MainWnd.cpp" line="232"/>
<source>About OpenGL</source> <source>About OpenGL</source>
<translation>Über OpenGL</translation> <translation>Über OpenGL</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="72"/> <location filename="../src/qt/MainWnd.cpp" line="72"/>
<source>Select translation...</source> <source>Select translation...</source>
<translation>Übersetzung auswählen...</translation> <translation type="obsolete">Übersetzung auswählen...</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="102"/> <location filename="../src/qt/MainWnd.cpp" line="102"/>
<source>Select translation</source> <source>Select translation</source>
<translation>Übersetzung auswählen</translation> <translation type="obsolete">Übersetzung auswählen</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="104"/> <location filename="../src/qt/MainWnd.cpp" line="104"/>
<source>Translation files (*.qm)</source> <source>Translation files (*.qm)</source>
<translation>Übersetzungsdateien (*.qm)</translation> <translation type="obsolete">Übersetzungsdateien (*.qm)</translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="107"/> <location filename="../src/qt/MainWnd.cpp" line="146"/>
<source>.qm</source> <source>.qm</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../src/qt/MainWnd.cpp" line="68"/> <location filename="../src/qt/MainWnd.cpp" line="91"/>
<source>Exit</source> <source>Exit</source>
<translation>Beenden</translation> <translation>Beenden</translation>
</message> </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> </context>
</TS> </TS>

156
lang/spanish.ts Normal file
View File

@ -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>&amp;File</source>
<translation>&amp;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>&amp;Settings</source>
<translation>&amp;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>&amp;Tools</source>
<translation>&amp;Herramientas</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="105"/>
<source>&amp;Help</source>
<translation>&amp;Ayuda</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="107"/>
<source>About &amp;VBA-M...</source>
<translation>Sobre &amp;VBA-M...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="108"/>
<source>About &amp;OpenGL...</source>
<translation>Sobre &amp;OpenGL...</translation>
</message>
<message>
<location filename="../src/qt/MainWnd.cpp" line="109"/>
<source>About &amp;Qt...</source>
<translation>Sobre &amp;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>

View File

@ -15,3 +15,4 @@ HEADERS += ../../src/qt/glwidget.h
SOURCES += ../../src/qt/glwidget.cpp SOURCES += ../../src/qt/glwidget.cpp
TRANSLATIONS += ../../lang/german.ts TRANSLATIONS += ../../lang/german.ts
TRANSLATIONS += ../../lang/spanish.ts

View File

@ -106,6 +106,10 @@
RelativePath="..\..\lang\german.ts" RelativePath="..\..\lang\german.ts"
> >
</File> </File>
<File
RelativePath="..\..\lang\spanish.ts"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Other" Name="Other"

View File

@ -27,13 +27,15 @@ MainWnd::MainWnd( QWidget *parent, QApplication *app, QTranslator **trans )
fileMenu( 0 ), fileMenu( 0 ),
settingsMenu( 0 ), settingsMenu( 0 ),
toolsMenu( 0 ), toolsMenu( 0 ),
helpMenu( 0 ) helpMenu( 0 ),
enableTranslationAct( 0 )
{ {
createDisplay(); createDisplay();
setMinimumSize( 320, 240 ); setMinimumSize( 320, 240 );
setWindowTitle( tr( "VBA-M" ) ); setWindowTitle( tr( "VBA-M" ) );
createActions();
createMenus(); 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() void MainWnd::createMenus()
{ {
if( fileMenu ) { if( fileMenu ) {
@ -63,17 +85,22 @@ void MainWnd::createMenus()
helpMenu = 0; helpMenu = 0;
} }
// File menu // File menu
fileMenu = menuBar()->addMenu( tr( "&File" ) ); fileMenu = menuBar()->addMenu( tr( "&File" ) );
fileMenu->addAction( tr( "Exit" ), this, SLOT( close() ) ); fileMenu->addAction( tr( "Exit" ), this, SLOT( close() ) );
// Settings menu // Settings menu
settingsMenu = menuBar()->addMenu( tr( "&Settings" ) ); 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 // Tools menu
toolsMenu = menuBar()->addMenu( tr( "&Tools" ) ); toolsMenu = menuBar()->addMenu( tr( "&Tools" ) );
// Help menu // Help menu
helpMenu = menuBar()->addMenu( tr( "&Help" ) ); helpMenu = menuBar()->addMenu( tr( "&Help" ) );
@ -95,31 +122,67 @@ bool MainWnd::createDisplay()
return false; return false;
} }
void MainWnd::selectTranslation() bool MainWnd::selectLanguage()
{ {
QString file = QFileDialog::getOpenFileName( QString file = QFileDialog::getOpenFileName(
this, this,
tr( "Select translation" ), tr( "Select language" ),
"lang", "lang",
tr( "Translation files (*.qm)" ) ); tr( "Language files (*.qm)" ) );
if( file.isNull() ) return; if( file.isNull() ) return false;
if( !file.endsWith( tr( ".qm" ), Qt::CaseInsensitive ) ) return;
// 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 ) { if( *translator != 0 ) {
theApp->removeTranslator( *translator );
delete *translator; delete *translator;
*translator = 0; *translator = 0;
} }
file.chop( 3 ); // remove file extension ".qm" file.chop( 3 ); // remove file extension ".qm"
// load new translation
*translator = new QTranslator(); *translator = new QTranslator();
(*translator)->load( file ); bool ret = (*translator)->load( file );
theApp->installTranslator( *translator ); 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 // apply translation
createMenus();
// the user might have to restart the application to apply changes completely // the user might have to restart the application to apply changes completely
createActions();
createMenus();
return true;
} }
void MainWnd::showAbout() void MainWnd::showAbout()

View File

@ -29,23 +29,28 @@ public:
MainWnd::MainWnd( QWidget *parent = 0, QApplication *app = 0, QTranslator **trans = 0 ); MainWnd::MainWnd( QWidget *parent = 0, QApplication *app = 0, QTranslator **trans = 0 );
MainWnd::~MainWnd(); MainWnd::~MainWnd();
public slots:
bool loadTranslation( QString file );
private: private:
void createActions();
void createMenus(); void createMenus();
bool createDisplay(); bool createDisplay();
private slots:
void selectTranslation();
void showAbout();
void showAboutOpenGL();
void showAboutQt();
private:
QApplication *theApp; QApplication *theApp;
QTranslator **translator; QTranslator **translator;
QMenu *fileMenu; QMenu *fileMenu;
QMenu *settingsMenu; QMenu *settingsMenu;
QAction *enableTranslationAct;
QMenu *toolsMenu; QMenu *toolsMenu;
QMenu *helpMenu; QMenu *helpMenu;
private slots:
bool selectLanguage();
bool enableTranslation( bool enable );
void showAbout();
void showAboutOpenGL();
void showAboutQt();
}; };
#endif // #ifndef MAINWND_H #endif // #ifndef MAINWND_H