Commit 9b441728 authored by Christophe Courtaut's avatar Christophe Courtaut

More effective translations

Translations preferences are now saved and loaded on startup.
.qm file are generated on make.
qmake does warning because translations file are added to ressources
but at this point translations files doesn't already exist.
parent a12adfc3
!isEmpty(TRANSLATIONS)
{
isEmpty(QMAKE_LRELEASE)
{
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(TS_DIR):TS_DIR = Translations
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM
PRE_TARGETDEPS += compiler_TSQM_make_all
}
<RCC>
<qresource prefix="/Lang" >
<file alias="es" >ts/vlmc_es.qm</file>
<file alias="fr" >ts/vlmc_fr.qm</file>
<file alias="sv" >ts/vlmc_sv.qm</file>
</qresource>
</RCC>
......@@ -58,10 +58,16 @@ void Preferences::on_pushButtonCancel_clicked()
}
void Preferences::on_pushButtonApply_clicked()
{
Preferences::changeLang( m_ui.comboBoxLanguage->itemData( m_ui.comboBoxLanguage->currentIndex() ).toString() );
close();
}
void Preferences::changeLang( QString langValue )
{
QSettings settings;
QString lang = settings.value( "Lang" ).toString();
QString langValue = m_ui.comboBoxLanguage->itemData( m_ui.comboBoxLanguage->currentIndex() ).toString();
settings.setValue( "Lang", langValue);
if ( m_currentLang != NULL )
{
qApp->removeTranslator( m_currentLang );
......@@ -71,8 +77,7 @@ void Preferences::on_pushButtonApply_clicked()
if ( !langValue.isEmpty() )
{
m_currentLang = new QTranslator();
m_currentLang->load( "vlmc_" + langValue, QApplication::applicationDirPath() + "/../" );
m_currentLang->load( langValue, ":/Lang/" );
qApp->installTranslator( m_currentLang );
}
close();
}
......@@ -38,6 +38,8 @@ public:
explicit Preferences( QWidget *parent = 0 );
virtual ~Preferences();
static void changeLang(QString lang);
protected:
virtual void changeEvent( QEvent *e );
......
......@@ -30,6 +30,7 @@ int main( int argc, char **argv )
app.setOrganizationName( "vlmc" );
app.setOrganizationDomain( "vlmc.org" );
QSettings::setDefaultFormat( QSettings::IniFormat );
Preferences::changeLang( QSettings().value( "Lang" ).toString() );
MainWindow w;
w.show();
return app.exec();
......
......@@ -56,11 +56,12 @@ FORMS += src/gui/ui/MainWindow.ui \
src/gui/ui/Timeline.ui \
src/gui/ui/LibraryWidget.ui
FORMS +=
RESOURCES +=
INCLUDEPATH += src/LibVLCpp
LIBS = -L/usr/local/lib \
-lvlc
TRANSLATIONS = ts/vlmc_es.ts \
ts/vlmc_fr.ts \
ts/vlmc_sv.ts
RESOURCES += ressources.qrc
INCLUDEPATH += src/LibVLCpp
LIBS = -L/usr/local/lib \
-lvlc
CODECFORTR = UTF-8
include(locale.pri)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment