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")
97 QString path = QString(
"/locales/%1.xml").arg(
m_localeCode.toLower());
106 LOG(VB_GENERAL, LOG_ERR,
107 QString(
"No locale defaults file for %1, skipping")
113 if (!
file.open(QIODevice::ReadOnly))
115 LOG(VB_GENERAL, LOG_ERR, QString(
"Unable to open %1")
116 .arg(
file.fileName()));
120 LOG(VB_GENERAL, LOG_NOTICE, QString(
"Reading locale defaults from %1")
121 .arg(
file.fileName()));
123 if (!doc.setContent(&
file))
125 LOG(VB_GENERAL, LOG_ERR, QString(
"Unable to parse %1")
126 .arg(
file.fileName()));
133 QDomElement docElem = doc.documentElement();
135 for (QDomNode n = docElem.firstChild(); !n.isNull();
138 QDomElement e = n.toElement();
141 if (e.tagName() ==
"setting")
143 QString name = e.attribute(
"name",
"");
144 bool global = (e.attribute(
"global",
"false") ==
"true");
145 QString value = e.firstChild().toText().data();
149 if (!name.isEmpty() && !value.isEmpty())
162 LOG(VB_GENERAL, LOG_ERR,
163 QString(
"No locale defaults specified in %1, skipping")
164 .arg(
file.fileName()));
177 SettingsMap::iterator it;
181 if (overwrite || mythDB->GetSetting(it.key()).isEmpty())
182 mythDB->SaveSettingOnHost(it.key(), it.value(),
"");
188 if (overwrite || mythDB->GetSetting(it.key()).isEmpty())
189 mythDB->SaveSetting(it.key(), it.value());