mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
Make rbutil check the system language and try to use the correct translation. A language selection in the configuration file will override this.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18118 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3f01df3f9c
commit
c367c21a76
3 changed files with 25 additions and 10 deletions
|
|
@ -37,7 +37,7 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_LANG "English (C)"
|
#define DEFAULT_LANG "English (en)"
|
||||||
|
|
||||||
Config::Config(QWidget *parent,int index) : QDialog(parent)
|
Config::Config(QWidget *parent,int index) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
@ -56,14 +56,13 @@ Config::Config(QWidget *parent,int index) : QDialog(parent)
|
||||||
QStringList langs = findLanguageFiles();
|
QStringList langs = findLanguageFiles();
|
||||||
for(int i = 0; i < langs.size(); ++i)
|
for(int i = 0; i < langs.size(); ++i)
|
||||||
lang.insert(languageName(langs.at(i)) + tr(" (%1)").arg(langs.at(i)), langs.at(i));
|
lang.insert(languageName(langs.at(i)) + tr(" (%1)").arg(langs.at(i)), langs.at(i));
|
||||||
lang.insert(DEFAULT_LANG, "");
|
lang.insert(DEFAULT_LANG, "en");
|
||||||
QMap<QString, QString>::const_iterator i = lang.constBegin();
|
QMap<QString, QString>::const_iterator i = lang.constBegin();
|
||||||
while (i != lang.constEnd()) {
|
while (i != lang.constEnd()) {
|
||||||
ui.listLanguages->addItem(i.key());
|
ui.listLanguages->addItem(i.key());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection);
|
ui.listLanguages->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||||
connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
|
|
||||||
ui.proxyPass->setEchoMode(QLineEdit::Password);
|
ui.proxyPass->setEchoMode(QLineEdit::Password);
|
||||||
ui.treeDevices->setAlternatingRowColors(true);
|
ui.treeDevices->setAlternatingRowColors(true);
|
||||||
ui.listLanguages->setAlternatingRowColors(true);
|
ui.listLanguages->setAlternatingRowColors(true);
|
||||||
|
|
@ -109,7 +108,7 @@ void Config::accept()
|
||||||
settings->setProxyType(proxyType);
|
settings->setProxyType(proxyType);
|
||||||
|
|
||||||
// language
|
// language
|
||||||
if(settings->curLang() != language)
|
if(settings->curLang() != language && !language.isEmpty())
|
||||||
QMessageBox::information(this, tr("Language changed"),
|
QMessageBox::information(this, tr("Language changed"),
|
||||||
tr("You need to restart the application for the changed language to take effect."));
|
tr("You need to restart the application for the changed language to take effect."));
|
||||||
settings->setLang(language);
|
settings->setLang(language);
|
||||||
|
|
@ -188,13 +187,19 @@ void Config::setUserSettings()
|
||||||
b = i.key();
|
b = i.key();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if(settings->curLang().startsWith(i.value(), Qt::CaseInsensitive)) {
|
||||||
|
// check if there is a base language (en -> en_US, etc.)
|
||||||
|
b = i.key();
|
||||||
|
break;
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
a = ui.listLanguages->findItems(b, Qt::MatchExactly);
|
a = ui.listLanguages->findItems(b, Qt::MatchExactly);
|
||||||
if(a.size() <= 0)
|
|
||||||
a = ui.listLanguages->findItems(DEFAULT_LANG, Qt::MatchExactly);
|
|
||||||
if(a.size() > 0)
|
if(a.size() > 0)
|
||||||
ui.listLanguages->setCurrentItem(a.at(0));
|
ui.listLanguages->setCurrentItem(a.at(0));
|
||||||
|
// don't connect before language list has been set up to prevent
|
||||||
|
// triggering the signal by selecting the saved language.
|
||||||
|
connect(ui.listLanguages, SIGNAL(itemSelectionChanged()), this, SLOT(updateLanguage()));
|
||||||
|
|
||||||
// devices tab
|
// devices tab
|
||||||
ui.mountPoint->setText(QDir::toNativeSeparators(settings->mountpoint()));
|
ui.mountPoint->setText(QDir::toNativeSeparators(settings->mountpoint()));
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,16 @@ int main( int argc, char ** argv ) {
|
||||||
user = new QSettings(absolutePath + "/RockboxUtility.ini", QSettings::IniFormat, 0);
|
user = new QSettings(absolutePath + "/RockboxUtility.ini", QSettings::IniFormat, 0);
|
||||||
else user = new QSettings(QSettings::IniFormat, QSettings::UserScope, "rockbox.org", "RockboxUtility");
|
else user = new QSettings(QSettings::IniFormat, QSettings::UserScope, "rockbox.org", "RockboxUtility");
|
||||||
|
|
||||||
|
QString applang = QLocale::system().name();
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
// install translator
|
// install translator
|
||||||
if(!user->value("lang", "").toString().isEmpty()) {
|
if(!user->value("lang", "").toString().isEmpty()) {
|
||||||
if(!translator.load("rbutil_" + user->value("lang").toString(), absolutePath))
|
applang = user->value("lang", "").toString();
|
||||||
translator.load("rbutil_" + user->value("lang").toString(), ":/lang");
|
}
|
||||||
QLocale::setDefault(user->value("lang").toString());
|
if(!applang.isEmpty()) {
|
||||||
|
if(!translator.load("rbutil_" + applang, absolutePath))
|
||||||
|
translator.load("rbutil_" + applang, ":/lang");
|
||||||
|
QLocale::setDefault(applang);
|
||||||
}
|
}
|
||||||
delete user;
|
delete user;
|
||||||
app.installTranslator(&translator);
|
app.installTranslator(&translator);
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,13 @@ QString RbSettings::curVoiceName()
|
||||||
|
|
||||||
QString RbSettings::curLang()
|
QString RbSettings::curLang()
|
||||||
{
|
{
|
||||||
return userSettings->value("lang").toString();
|
// QSettings::value only returns the default when the setting
|
||||||
|
// doesn't exist. Make sure to return the system language if
|
||||||
|
// the language in the configuration is present but empty too.
|
||||||
|
QString lang = userSettings->value("lang").toString();
|
||||||
|
if(lang.isEmpty())
|
||||||
|
lang = QLocale::system().name();
|
||||||
|
return lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RbSettings::curEncoder()
|
QString RbSettings::curEncoder()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue