Changeset View
Changeset View
Standalone View
Standalone View
step/infobrowser.cc
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Line(s) | 147 | "<div id='doc_box-body' class='box-body'>\n" | |||
---|---|---|---|---|---|
148 | "<div class='info'><p>\n" | 148 | "<div class='info'><p>\n" | ||
149 | + i18n("No current object.") + | 149 | + i18n("No current object.") + | ||
150 | "</p></div>\n" | 150 | "</p></div>\n" | ||
151 | "</div>\n" | 151 | "</div>\n" | ||
152 | "</div>\n" | 152 | "</div>\n" | ||
153 | "</body></html>", fromHistory, url ); | 153 | "</body></html>", fromHistory, url ); | ||
154 | return; | 154 | return; | ||
155 | } | 155 | } | ||
156 | QString fileName = QStringLiteral(":/objectinfo/%1.html").arg(className.toLower()); | 156 | QString fileName = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("objinfo/%1/%2.html").arg(QLocale::system().uiLanguages().at(0), className.toLower())); | ||
157 | if(fileName.isEmpty()) { | ||||
158 | fileName = QStringLiteral(":/objectinfo/%1.html").arg(className.toLower()); | ||||
cordlandwehr: In my opinion, I would prefer to stick with the resource-based location for the un-translated… | |||||
159 | } | ||||
I think using KLocalizedString::languages() here makes more sense, i think QLocale uses a bit of a different naming system for "complex" stuff like pt_BR aacid: I think using KLocalizedString::languages() here makes more sense, i think QLocale uses a bit… | |||||
can i convince you to iterate over KLocalizedString::languages instead of using the first one only? This way we will try all the langauges you may have selected and then only fallback to english if none was found aacid: can i convince you to iterate over KLocalizedString::languages instead of using the first one… | |||||
or even better, use KLocalizedString::localizedFilePath() to locate the translated html file? pino: > can i convince you to iterate over KLocalizedString::languages instead of using the first one… | |||||
157 | if(!fileName.isEmpty()) { | 160 | if(!fileName.isEmpty()) { | ||
158 | QFile file(fileName); | 161 | QFile file(fileName); | ||
159 | if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { | 162 | if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
160 | setHtml(QString::fromUtf8(file.readAll()), fromHistory, url); | 163 | setHtml(QString::fromUtf8(file.readAll()), fromHistory, url); | ||
161 | return; | 164 | return; | ||
162 | } else { | 165 | } else { | ||
163 | qWarning() << "Could not open help file at location:" << fileName; | 166 | qWarning() << "Could not open help file at location:" << fileName; | ||
164 | } | 167 | } | ||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |
In my opinion, I would prefer to stick with the resource-based location for the un-translated HTML files. This makes the development setup (slightly) simpler because no XDG_DATA_DIRS variable must be set and the default handling is easier to break. Actually, the default HTML files would be a fallback even if the environment variables are set incorrectly.