Commit 1dbc30f6 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Load the translations from the resources.

parent ea7d408e
......@@ -35,14 +35,14 @@ LanguagePreferences::LanguagePreferences( QWidget *parent )
{
m_ui.setupUi( this );
QDir dir( TS_DIR, "*.qm", QDir::Name | QDir::IgnoreCase, QDir::Files );
QDir dir( ":/ts/", "*.qm", QDir::Name | QDir::IgnoreCase, QDir::Files );
QStringList tss = dir.entryList();
m_ui.comboBoxLanguage->setInsertPolicy( QComboBox::InsertAlphabetically );
foreach ( const QString& tsFileName, tss )
{
QString localeStr;
int localePos = tsFileName.lastIndexOf( "vlmc_");
int localePos = tsFileName.lastIndexOf( TS_PREFIX );
int dotPos = tsFileName.lastIndexOf( ".qm" );
if ( localePos < 0 || dotPos < 0 )
{
......@@ -52,12 +52,11 @@ LanguagePreferences::LanguagePreferences( QWidget *parent )
localePos += 5;
localeStr = tsFileName.mid( localePos, dotPos - localePos );
QLocale locale( localeStr );
qDebug() << "Adding new language:" << QLocale::countryToString( locale.country() ) << '/' <<
QLocale::languageToString( locale.language() ) << "with locale" << localeStr;
m_ui.comboBoxLanguage->addItem( QLocale::countryToString( locale.country() ) + " / "
+ QLocale::languageToString( locale.language() ), localeStr );
m_ui.comboBoxLanguage->addItem( QString( "%1 (%2)" ).arg(
QLocale::languageToString( locale.language() ),
QLocale::countryToString( locale.country() ) ), localeStr );
}
m_ui.comboBoxLanguage->addItem( "UnitedStates / English", "en_US" );
m_ui.comboBoxLanguage->addItem( "English (UnitedStates)", "en_US" );
}
LanguagePreferences::~LanguagePreferences() {}
......@@ -94,7 +93,7 @@ void LanguagePreferences::changeLang( QString langValue )
if ( !langValue.isEmpty() )
{
m_currentLang = new QTranslator();
m_currentLang->load( langValue, ":/Lang/" );
m_currentLang->load( TS_PREFIX + langValue, ":/ts/" );
qApp->installTranslator( m_currentLang );
}
}
......
......@@ -29,6 +29,8 @@
#include "PreferenceWidget.h"
#include "ui_LanguagePreferences.h"
#define TS_PREFIX "vlmc_"
class LanguagePreferences : public PreferenceWidget
{
Q_OBJECT
......
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