Skip to content

Commit

Permalink
- Use QLocale instead of strings.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12449 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Aug 7, 2012
1 parent de00b3d commit c5a3489
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
5 changes: 2 additions & 3 deletions OMEdit/OMEditGUI/OMCProxy.cpp
Expand Up @@ -245,11 +245,10 @@ bool OMCProxy::startServer()
mObjectRefFile = objectRefFile.fileName();
// read the locale
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "openmodelica", "omedit");
QString language = settings.value("language").toString();
QString locale = language.isEmpty() ? QLocale::system().name() : language;
QLocale settingsLocale = settings.value("language").toLocale();
// Start the omc.exe
QStringList parameters;
parameters << QString("+c=").append(mName).append(fileIdentifier) << QString("+d=interactiveCorba") << QString("+locale=").append(locale);
parameters << QString("+c=").append(mName).append(fileIdentifier) << QString("+d=interactiveCorba") << QString("+locale=").append(settingsLocale.name());
QProcess *omcProcess = new QProcess();
QFile omcOutputFile;
#ifdef WIN32 // Win32
Expand Down
31 changes: 15 additions & 16 deletions OMEdit/OMEditGUI/OptionsWidget.cpp
Expand Up @@ -229,7 +229,7 @@ void OptionsWidget::readGeneralSettings()
// read the language option
if (mSettings.contains("language"))
{
if (!mSettings.value("language").toString().isEmpty())
if (!mSettings.value("language").toLocale().name().isEmpty())
{
int currentIndex = mpGeneralSettingsPage->getLanguageComboBox()->findData(mSettings.value("language"), Qt::UserRole, Qt::MatchExactly);
mpGeneralSettingsPage->getLanguageComboBox()->setCurrentIndex(currentIndex);
Expand Down Expand Up @@ -357,7 +357,7 @@ void OptionsWidget::readLibrariesSettings()
void OptionsWidget::saveGeneralSettings()
{
// save Language option
mSettings.setValue("language", mpGeneralSettingsPage->getLanguageComboBox()->itemData(mpGeneralSettingsPage->getLanguageComboBox()->currentIndex()).toString());
mSettings.setValue("language", mpGeneralSettingsPage->getLanguageComboBox()->itemData(mpGeneralSettingsPage->getLanguageComboBox()->currentIndex()));
// save plotting view mode
mSettings.setValue("plotting/viewmode", mpGeneralSettingsPage->getViewMode());
if (mpGeneralSettingsPage->getViewMode().compare("SubWindow") == 0)
Expand Down Expand Up @@ -559,24 +559,23 @@ GeneralSettingsPage::GeneralSettingsPage(OptionsWidget *pParent)
mpLanguageComboBox = new QComboBox;
mpLanguageComboBox->addItem(tr("Auto Detected"), "");
/* Slow sorting, but works using regular Qt functions */
QMap<QString,QString> map;
map.insert(tr("Chinese"), "zh_CN");
map.insert(tr("English"), "en");
map.insert(tr("French"), "fr");
map.insert(tr("German"), "de");
map.insert(tr("Italian"), "it");
map.insert(tr("Japanese"), "ja");
map.insert(tr("Romanian"), "ro");
map.insert(tr("Russian"), "ru");
map.insert(tr("Spanish"), "es");
map.insert(tr("Swedish"), "sv");
QMap<QString, QLocale> map;
map.insert(tr("Chinese").append(" (zh_CN)"), QLocale(QLocale::Chinese));
map.insert(tr("English").append(" (en)"), QLocale(QLocale::English));
map.insert(tr("French").append(" (fr)"), QLocale(QLocale::French));
map.insert(tr("German").append(" (de)"), QLocale(QLocale::German));
map.insert(tr("Italian").append(" (it)"), QLocale(QLocale::Italian));
map.insert(tr("Japanese").append(" (ja)"), QLocale(QLocale::Japanese));
map.insert(tr("Romanian").append(" (ro)"), QLocale(QLocale::Romanian));
map.insert(tr("Russian").append(" (ru)"), QLocale(QLocale::Russian));
map.insert(tr("Spanish").append(" (es)"), QLocale(QLocale::Spanish));
map.insert(tr("Swedish").append(" (sv)"), QLocale(QLocale::Swedish));
QStringList keys(map.keys());
keys.sort();
foreach (const QString &key, keys) {
QString val = map[key];
mpLanguageComboBox->addItem(key + " ("+val+")",val);
QLocale locale = map[key];
mpLanguageComboBox->addItem(key, locale);
}

// Plotting View Mode
mpPlottingViewModeLabel = new QLabel(tr("Plotting View Mode:"));
mpTabbedViewRadioButton = new QRadioButton(tr("Tabbed View"));
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/main.cpp
Expand Up @@ -77,9 +77,9 @@ int main(int argc, char *argv[])
omhome = omhome ? omhome : CONFIG_DEFAULT_OPENMODELICAHOME;
#endif
QSettings settings(QSettings::IniFormat, QSettings::UserScope, "openmodelica", "omedit");
QString language = settings.value("language").toString();
QLocale settingsLocale = settings.value("language").toLocale();
QString locale = settingsLocale.name().isEmpty() ? QLocale::system().name() : settingsLocale.name();
QString translationDirectory = omhome + QString("/share/omedit/nls");
QString locale = language.isEmpty() ? QLocale::system().name() : language;
// install Qt's default translations
QTranslator qtTranslator;
#ifdef Q_OS_WIN
Expand Down

0 comments on commit c5a3489

Please sign in to comment.