Replace list of languages with map.

- Use ISO codes as keys for voice languages instead of enumeration.
- Instead of trying to select a suitable voicefile language from the UI
  language use the ISO codes stored as UI language and match against the
  mapping.
- Always store the selected UI language. Fixes the voicefile creation
  language lookup to fail if the language used is the system language.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29207 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Riebeling 2011-02-04 23:28:34 +00:00
parent 3419422c23
commit 988b3083df
6 changed files with 60 additions and 56 deletions

View file

@ -143,16 +143,16 @@ QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString va
return result; return result;
} }
QStringList SystemInfo::languages() QMap<QString, QString> SystemInfo::languages(void)
{ {
ensureSystemInfoExists(); ensureSystemInfoExists();
QStringList result; QMap<QString, QString> result;
systemInfos->beginGroup("languages"); systemInfos->beginGroup("languages");
QStringList a = systemInfos->childKeys(); QStringList a = systemInfos->childKeys();
for(int i = 0; i < a.size(); i++) for(int i = 0; i < a.size(); i++)
{ {
result.append(systemInfos->value(a.at(i), "null").toString()); result.insert(a.at(i), systemInfos->value(a.at(i), "null").toString());
} }
systemInfos->endGroup(); systemInfos->endGroup();
return result; return result;

View file

@ -78,8 +78,8 @@ class SystemInfo : public QObject
//! return a list of all platforms (rbutil internal names) //! return a list of all platforms (rbutil internal names)
static QStringList platforms(enum PlatformType type = PlatformAll, static QStringList platforms(enum PlatformType type = PlatformAll,
QString variant=""); QString variant="");
//! returns a list of all languages //! returns a map of all languages
static QStringList languages(void); static QMap<QString, QString> languages(void);
//! returns a map of usb-ids and their targets //! returns a map of usb-ids and their targets
static QMap<int, QString> usbIdMap(enum MapType); static QMap<int, QString> usbIdMap(enum MapType);
//! get a value from system settings //! get a value from system settings

View file

@ -38,11 +38,10 @@ TTSBase::Capabilities TTSSapi::capabilities()
void TTSSapi::generateSettings() void TTSSapi::generateSettings()
{ {
// language // language
QStringList languages = SystemInfo::languages(); QMap<QString, QString> languages = SystemInfo::languages();
languages.sort();
EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST, EncTtsSetting* setting =new EncTtsSetting(this,EncTtsSetting::eSTRINGLIST,
tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage), tr("Language:"),RbSettings::subValue("sapi",RbSettings::TtsLanguage),
languages); languages.values());
connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList())); connect(setting,SIGNAL(dataChanged()),this,SLOT(updateVoiceList()));
insertSetting(eLANGUAGE,setting); insertSetting(eLANGUAGE,setting);
// voice // voice

View file

@ -131,9 +131,10 @@ void Config::accept()
if(RbSettings::value(RbSettings::Language).toString() != language if(RbSettings::value(RbSettings::Language).toString() != language
&& !language.isEmpty()) { && !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 "
RbSettings::setValue(RbSettings::Language, language); "to take effect."));
} }
RbSettings::setValue(RbSettings::Language, language);
// mountpoint // mountpoint
QString mp = ui.mountPoint->text(); QString mp = ui.mountPoint->text();

View file

@ -71,17 +71,21 @@ void CreateVoiceWindow::accept()
void CreateVoiceWindow::updateSettings(void) void CreateVoiceWindow::updateSettings(void)
{ {
// fill in language combobox // fill in language combobox
QStringList languages = SystemInfo::languages(); QMap<QString, QString> languages = SystemInfo::languages();
languages.sort();
ui.comboLanguage->addItems(languages); for(int i = 0; i < languages.keys().size(); i++) {
QString key = languages.keys().at(i);
ui.comboLanguage->addItem(languages.value(key), key);
}
// set saved lang // set saved lang
int sel = ui.comboLanguage->findText(RbSettings::value(RbSettings::VoiceLanguage).toString()); int sel = ui.comboLanguage->findText(
RbSettings::value(RbSettings::VoiceLanguage).toString());
// if no saved language is found try to figure the language from the UI lang // if no saved language is found try to figure the language from the UI lang
if(sel == -1) { if(sel == -1) {
QString f = RbSettings::value(RbSettings::Language).toString(); QString f = RbSettings::value(RbSettings::Language).toString();
// if no language is set default to english. Make sure not to check an empty string. // if no language is set default to english. Make sure not to check an empty string.
if(f.isEmpty()) f = "english"; if(f.isEmpty()) f = "english";
sel = ui.comboLanguage->findText(f, Qt::MatchStartsWith); sel = ui.comboLanguage->findData(f);
qDebug() << "sel =" << sel; qDebug() << "sel =" << sel;
// still nothing found? // still nothing found?
if(sel == -1) if(sel == -1)

View file

@ -755,42 +755,42 @@ name="Sansa View"
[languages] [languages]
lang1=afrikaans af=afrikaans
lang2=bulgarian bg=bulgarian
lang3=catala ca=catala
lang4=chinese-simp cs=czech
lang5=chinese-trad da=dansk
lang6=czech de=deutsch
lang7=dansk el=greek
lang8=deutsch en=english
lang9=eesti eo=esperanto
lang10=english es=espanol
lang11=espanol et=eesti
lang12=esperanto fi=finnish
lang13=finnish fr=francais
lang14=francais gl=galego
lang15=galego he=hebrew
lang16=greek hi=hindi
lang17=hebrew hu=magyar
lang18=islenska is=islenska
lang19=italiano it=italiano
lang20=japanese ja=japanese
lang21=korean ko=korean
lang22=magyar lt=lietuviu
lang23=nederlands nb=norsk
lang24=norsk nl=nederlands
lang25=norsk-nynorsk nn=norsk-nynorsk
lang26=polski pl=polski
lang27=portugues pt=portugues
lang28=portugues-brasileiro pt_BR=portugues-brasileiro
lang29=romaneste ro=romaneste
lang30=russian ru=russian
lang31=slovenscina sk=slovenscina
lang32=svenska sv=svenska
lang33=thai th=thai
lang34=turkce tl=tagalog
lang35=wallisertitsch tr=turkce
lang36=hindi wa=wallisertitsch
lang37=tagalog zh_CN=chinese-simp
lang38=lietuviu zh_TW=chinese-trad