From a0a6759d930c081d95d0984b4ffdbd1a55cf4961 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 6 Jun 2014 12:10:34 -0700 Subject: User manual: show a localized version of the manual if it exists So far we only have Spanish, but it always pays to plan ahead. Signed-off-by: Dirk Hohndel --- qt-ui/usermanual.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/usermanual.cpp b/qt-ui/usermanual.cpp index 82691594c..3985b6cd4 100644 --- a/qt-ui/usermanual.cpp +++ b/qt-ui/usermanual.cpp @@ -1,10 +1,12 @@ #include #include +#include +#include #include "usermanual.h" #include "ui_usermanual.h" -#include "../helpers.h" +#include "helpers.h" UserManual::UserManual(QWidget *parent) : QMainWindow(parent), ui(new Ui::UserManual) @@ -31,7 +33,15 @@ UserManual::UserManual(QWidget *parent) : QMainWindow(parent), ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); QString searchPath = getSubsurfaceDataPath("Documentation"); if (searchPath.size()) { - QUrl url(searchPath.append("/user-manual.html")); + // look for localized versions of the manual first + QString lang = uiLanguage(NULL); + QString prefix = searchPath.append("/user-manual"); + QFile manual(prefix + "_" + lang + ".html"); + if (!manual.exists()) + manual.setFileName(prefix + "_" + lang.left(2) + ".html"); + if (!manual.exists()) + manual.setFileName(prefix + ".html"); + QUrl url(manual.fileName()); ui->webView->setUrl(url); } else { ui->webView->setHtml(tr("Cannot find the Subsurface manual")); -- cgit v1.2.3-70-g09d2