Show nicer language names in voice creation dialog.

Instead of showing the internal language names show some more human friendly
string. Currently only applies to the voice creation dialog, the language
configuration dialog needs further adjustments to support display strings
differing from values.

Change-Id: Ic94838f1079c1d09a666d7dbd9682c577f686b3f
This commit is contained in:
Dominik Riebeling 2012-05-19 16:49:48 +02:00
parent 9f89ffa71c
commit 733eb9af40
5 changed files with 65 additions and 59 deletions

View file

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

View file

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

View file

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

View file

@ -52,7 +52,7 @@ void CreateVoiceWindow::accept()
//configure voicecreator
voicecreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
voicecreator->setLang(ui.comboLanguage->currentText());
voicecreator->setLang(ui.comboLanguage->itemData(ui.comboLanguage->currentIndex()).toString());
voicecreator->setWavtrimThreshold(ui.wavtrimthreshold->value());
//start creating
@ -69,25 +69,25 @@ void CreateVoiceWindow::accept()
void CreateVoiceWindow::updateSettings(void)
{
// fill in language combobox
QMap<QString, QString> languages = SystemInfo::languages();
QMap<QString, QStringList> languages = SystemInfo::languages();
for(int i = 0; i < languages.keys().size(); i++) {
QString key = languages.keys().at(i);
ui.comboLanguage->addItem(languages.value(key), key);
ui.comboLanguage->addItem(languages.value(key).at(1), languages.value(key).at(0));
}
// set saved lang
int sel = ui.comboLanguage->findText(
int sel = ui.comboLanguage->findData(
RbSettings::value(RbSettings::VoiceLanguage).toString());
// if no saved language is found try to figure the language from the UI lang
if(sel == -1) {
QString f = RbSettings::value(RbSettings::Language).toString();
QString uilang = RbSettings::value(RbSettings::Language).toString();
// if no language is set default to english. Make sure not to check an empty string.
if(f.isEmpty()) f = "english";
QString f = "english";
if(!uilang.isEmpty() && languages.contains(uilang)) {
f = languages.value(uilang).at(0);
}
sel = ui.comboLanguage->findData(f);
qDebug() << "sel =" << sel;
// still nothing found?
if(sel == -1)
sel = ui.comboLanguage->findText("english", Qt::MatchStartsWith);
qDebug() << "[CreateVoiceWindow] Selected language index:" << sel;
}
ui.comboLanguage->setCurrentIndex(sel);
@ -125,7 +125,7 @@ void CreateVoiceWindow::saveSettings(void)
{
// save selected language
RbSettings::setValue(RbSettings::VoiceLanguage,
ui.comboLanguage->currentText());
ui.comboLanguage->itemData(ui.comboLanguage->currentIndex()).toString());
// save wavtrim threshold value
RbSettings::setValue(RbSettings::WavtrimThreshold,
ui.wavtrimthreshold->value());

View file

@ -849,47 +849,49 @@ name="Sansa Fuze+ (Recovery Mode)"
; The language string is sent to the server when retrieving the list of
; strings. Each entry name is the code for the language and used for storing in
; the configuration.
; Format:
; <language code>=<language string as sent to server>,<human readable string>
[languages]
af=afrikaans
bg=bulgarian
ca=catala
cs=czech
da=dansk
de=deutsch
el=greek
en=english
en_US=english-us
eo=esperanto
es=espanol
et=eesti
eu=basque
fi=finnish
fr=francais
gl=galego
he=hebrew
hi=hindi
hu=magyar
is=islenska
it=italiano
ja=japanese
ko=korean
lt=lietuviu
lv=latviesu
nb=norsk
nl=nederlands
nn=norsk-nynorsk
pl=polski
pt=portugues
pt_BR=portugues-brasileiro
ro=romaneste
ru=russian
sk=slovak
sl=slovenscina
sv=svenska
th=thai
tl=tagalog
tr=turkce
wa=wallisertitsch
zh_CN=chinese-simp
zh_TW=chinese-trad
af=afrikaans,Afrikaans
bg=bulgarian,Bulgarian
ca=catala,Catala
cs=czech,Czech
da=dansk,Dansk
de=deutsch,Deutsch
el=greek,Greek
en=english,English (UK)
en_US=english-us,English (US)
eo=esperanto,Esperanto
es=espanol,Espanol
et=eesti,Eesti
eu=basque,Basque
fi=finnish,Finnish
fr=francais,Francais
gl=galego,Galego
he=hebrew,Hebrew
hi=hindi,Hindi
hu=magyar,Magyar
is=islenska,Islenska
it=italiano,Italiano
ja=japanese,Japanese
ko=korean,Korean
lt=lietuviu,Lietuviu
lv=latviesu,Latviesu
nb=norsk,Norsk
nl=nederlands,Netherlands
nn=norsk-nynorsk,Norsk (Nyorsk)
pl=polski,Polski
pt=portugues,Portugues
pt_BR=portugues-brasileiro,Portugues (Brasileiro)
ro=romaneste,Romaneste
ru=russian,Russian
sk=slovak,Slovak
sl=slovenscina,Slovenscina
sv=svenska,Svenska
th=thai,Thai
tl=tagalog,Tagalog
tr=turkce,Turkce
wa=wallisertitsch,Wallisertitsch
zh_CN=chinese-simp,Chinese (simplified)
zh_TW=chinese-trad,Chinese (traditional)