Commit 37bc4006 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen
Browse files

Generating translation list at runtime

parent a5f1f960
...@@ -26,19 +26,35 @@ ...@@ -26,19 +26,35 @@
#include "LanguagePreferences.h" #include "LanguagePreferences.h"
#include "ui_LanguagePreferences.h" #include "ui_LanguagePreferences.h"
#include <QDir>
QTranslator* LanguagePreferences::m_currentLang = NULL; QTranslator* LanguagePreferences::m_currentLang = NULL;
LanguagePreferences::LanguagePreferences( QWidget *parent ) LanguagePreferences::LanguagePreferences( QWidget *parent )
: PreferenceWidget( parent ) : PreferenceWidget( parent )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
m_ui.comboBoxLanguage->addItem( tr( "Czech" ), "cs" );
m_ui.comboBoxLanguage->addItem( tr( "English" ), "en" ); QDir dir( "ts/", "*.ts", QDir::Name | QDir::IgnoreCase, QDir::Files );
m_ui.comboBoxLanguage->addItem( tr( "French" ), "fr" ); QStringList tss = dir.entryList();
m_ui.comboBoxLanguage->addItem( tr( "Japanese" ), "jp" );
m_ui.comboBoxLanguage->addItem( tr( "Spanish" ), "es" ); foreach ( const QString& tsFileName, tss )
m_ui.comboBoxLanguage->addItem( tr( "Swedish" ), "sv" ); {
m_ui.comboBoxLanguage->addItem( tr( "Brazilian Portugese" ), "pt_BR" ); QString localeStr;
int localePos = tsFileName.lastIndexOf( "vlmc_");
int dotPos = tsFileName.lastIndexOf( ".ts" );
if ( localePos < 0 || dotPos < 0 )
{
qWarning() << "Invalid translation file:" << tsFileName;
continue ;
}
localePos += 5;
localeStr = tsFileName.mid( localePos, dotPos - localePos );
QLocale locale( localeStr );
m_ui.comboBoxLanguage->addItem( QLocale::countryToString( locale.country() ) + " / "
+ QLocale::languageToString( locale.language() ), localeStr );
}
m_ui.comboBoxLanguage->addItem( "UnitedStates / English", "en" );
} }
LanguagePreferences::~LanguagePreferences() {} LanguagePreferences::~LanguagePreferences() {}
......
Supports Markdown
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