=== modified file 'mixxx/src/dlgprefcontrols.cpp' --- mixxx/src/dlgprefcontrols.cpp 2012-05-04 11:57:59 +0000 +++ mixxx/src/dlgprefcontrols.cpp 2012-05-10 01:55:42 +0000 @@ -20,6 +20,7 @@ #include #include #include +#include #include "dlgprefcontrols.h" #include "qcombobox.h" @@ -153,6 +154,45 @@ connect(ComboBoxAllowTrackLoadToPlayingDeck, SIGNAL(activated(int)), this, SLOT(slotSetAllowTrackLoadToPlayingDeck(int))); // + // Locale setting + // + + // Iterate through the available locales and add them to the combobox + // Borrowed following snippet from http://qt-project.org/wiki/How_to_create_a_multi_language_application + QString translationsFolder = m_pConfig->getConfigPath() + "translations/"; + QString currentLocale = pConfig->getValueString(ConfigKey("[Config]","Locale")); + + QDir translationsDir(translationsFolder); + QStringList fileNames = translationsDir.entryList(QStringList("mixxx_*.qm")); + + ComboBoxLocale->addItem("System", ""); // System default locale + + int currentLocaleIndex = 1; + + for (int i = 0; i < fileNames.size(); ++i) { + // Extract locale from filename + QString locale = fileNames[i]; + locale.truncate(locale.lastIndexOf('.')); + locale.remove(0, locale.indexOf('_') + 1); + + QString lang = QLocale::languageToString(QLocale(locale).language()); + + if (lang == "C") { // Ugly hack to remove the non-resolving locales + currentLocaleIndex++; + continue; + } + + ComboBoxLocale->addItem(lang, locale); // locale as userdata (for storing to config) + + if (locale == currentLocale) { // Set the currently selected locale + ComboBoxLocale->setCurrentIndex(currentLocaleIndex); + } + currentLocaleIndex++; + } + + connect(ComboBoxLocale, SIGNAL(activated(int)), this, SLOT(slotSetLocale(int))); + + // // Default Cue Behavior // @@ -324,6 +364,17 @@ ComboBoxRateDir->setCurrentIndex(1); } +void DlgPrefControls::slotSetLocale(int pos) +{ + QString newLocale = ComboBoxLocale->itemData(pos).toString(); + m_pConfig->set(ConfigKey("[Config]","Locale"), ConfigValue(newLocale)); + + // Notify the user that a reboot is necessary + QMessageBox::information(this, tr("Information"), + tr("Mixxx must be restarted before the changes will take effect.")); + +} + void DlgPrefControls::slotSetRateRange(int pos) { float range = (float)(pos-1)/10.; === modified file 'mixxx/src/dlgprefcontrols.h' --- mixxx/src/dlgprefcontrols.h 2012-04-25 04:10:59 +0000 +++ mixxx/src/dlgprefcontrols.h 2012-05-10 01:33:23 +0000 @@ -60,6 +60,7 @@ void slotSetCueRecall(int); void slotSetRateRamp(bool); void slotSetRateRampSensitivity(int); + void slotSetLocale(int); void slotApply(); void slotSetFrameRate(int frameRate); === modified file 'mixxx/src/dlgprefcontrolsdlg.ui' --- mixxx/src/dlgprefcontrolsdlg.ui 2012-05-09 12:58:08 +0000 +++ mixxx/src/dlgprefcontrolsdlg.ui 2012-05-10 01:33:23 +0000 @@ -257,6 +257,19 @@ + + + + Locale + + + ComboBoxLocale + + + + + + === modified file 'mixxx/src/mixxx.cpp' --- mixxx/src/mixxx.cpp 2012-05-08 16:10:02 +0000 +++ mixxx/src/mixxx.cpp 2012-05-10 01:39:11 +0000 @@ -142,6 +142,11 @@ QString userLocale = args.locale; QLocale systemLocale = QLocale::system(); + // Attempt to load user locale from config + if (userLocale == "") { + userLocale = m_pConfig->getValueString(ConfigKey("[Config]","Locale")); + } + // Load Qt translations for this locale from the system translation // path. This is the lowest precedence QTranslator. QTranslator* qtTranslator = new QTranslator(a);