5 #include <QDomDocument>
23 QString dbLanguage =
GetMythDB()->GetSetting(
"Language",
"");
24 QString dbCountry =
GetMythDB()->GetSetting(
"Country",
"");
26 if (!localeName.isEmpty())
30 else if (!dbLanguage.isEmpty() &&
33 QString langcode = dbLanguage.section(
'_',0,0);
34 m_localeCode = QString(
"%1_%2").arg(langcode, dbCountry.toUpper());
38 QLocale locale = QLocale::system();
40 if (locale.name().isEmpty() || locale.name() ==
"C")
99 QString path = QString(
"/locales/%1.xml").arg(
m_localeCode.toLower());
108 LOG(VB_GENERAL, LOG_ERR,
109 QString(
"No locale defaults file for %1, skipping")
115 if (!
file.open(QIODevice::ReadOnly))
117 LOG(VB_GENERAL, LOG_ERR, QString(
"Unable to open %1")
118 .arg(
file.fileName()));
122 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Reading locale defaults from %1")
123 .arg(
file.fileName()));
125 if (!doc.setContent(&
file))
127 LOG(VB_GENERAL, LOG_ERR, QString(
"Unable to parse %1")
128 .arg(
file.fileName()));
135 QDomElement docElem = doc.documentElement();
137 for (QDomNode n = docElem.firstChild(); !n.isNull();
140 QDomElement e = n.toElement();
143 if (e.tagName() ==
"setting")
145 QString name = e.attribute(
"name",
"");
146 bool global = (e.attribute(
"global",
"false") ==
"true");
147 QString value = e.firstChild().toText().data();
151 if (!name.isEmpty() && !value.isEmpty())
164 LOG(VB_GENERAL, LOG_ERR,
165 QString(
"No locale defaults specified in %1, skipping")
166 .arg(
file.fileName()));
179 SettingsMap::iterator it;
183 if (overwrite || mythDB->GetSetting(it.key()).isEmpty())
184 mythDB->SaveSettingOnHost(it.key(), it.value(),
"");
190 if (overwrite || mythDB->GetSetting(it.key()).isEmpty())
191 mythDB->SaveSetting(it.key(), it.value());