From d8638fa42bce3a10e53f529739b89009d327c082 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 27 Dec 2018 09:03:29 +0200 Subject: [PATCH] Changed: For ingame help html files, use english files as fallback. --HG-- branch : develop --- .../src/interface_v3/group_quick_help.cpp | 54 +++++++++++++++---- .../src/interface_v3/group_quick_help.h | 5 ++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index b3c2c1ecc..144dc9b9a 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -297,6 +297,49 @@ void CGroupQuickHelp::beginElement (uint element_number, const std::vector } } +// *************************************************************************** +std::string CGroupQuickHelp::getLanguageUrl(const std::string &href, std::string lang) const +{ + std::string uri = href; + + if (uri.size() < 5 || uri.substr(0, 5) == "http://" || uri.substr(0, 6) == "https://") + { + return uri; + } + + // modify uri such that '_??.html' ending contains current user language + if (uri.substr(uri.size()-5) == ".html") + { + if (uri.rfind("_") == uri.size() - 8) + { + uri = uri.substr(0, uri.size() - 8); + } + else + { + uri = uri.substr(0, uri.size() - 5); + } + uri += "_" + lang + ".html"; + + // files inside bnp (file:/gamedev.bnp@help_en.html) will always match with CPath::lookup() + std::string fname; + size_t pos = uri.find("@"); + if (pos != std::string::npos) + { + fname = uri.substr(pos+1); + } + else + { + fname = uri; + } + if (CPath::lookup(fname, false) == "" && lang != "en") + { + uri = getLanguageUrl(href, "en"); + } + } + + return uri; +} + // *************************************************************************** void CGroupQuickHelp::browse (const char *url) @@ -307,12 +350,7 @@ void CGroupQuickHelp::browse (const char *url) _IsQuickHelp = false; - string completeURL = url; - if (completeURL.substr(completeURL.size()-5, 5) == ".html") - { - completeURL = completeURL.substr(0, completeURL.size()-5); // Substract the ".html" - completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html"; - } + string completeURL = getLanguageUrl(url, ClientCfg.getHtmlLanguageCode()); CGroupHTML::browse (completeURL.c_str()); } @@ -321,9 +359,7 @@ void CGroupQuickHelp::browse (const char *url) std::string CGroupQuickHelp::home() { - string completeURL = Home; - completeURL = completeURL.substr(0, completeURL.size()-5); // Substract the ".html" - completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html"; + string completeURL = getLanguageUrl(Home, ClientCfg.getHtmlLanguageCode()); return completeURL; } diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.h b/code/ryzom/client/src/interface_v3/group_quick_help.h index 76f863bf9..3dc1c8afa 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.h +++ b/code/ryzom/client/src/interface_v3/group_quick_help.h @@ -53,6 +53,11 @@ private: virtual void browse (const char *url); virtual std::string home(); + // Modify uri with '.html' or '_??.html' ending to have current user language, + // If the uri is not found locally, then try "en" as fallback language + // ie. 'help_ru.html' does not exists, return 'help_en.html' + std::string getLanguageUrl(const std::string &href, std::string lang) const; + // Init parsing value void initParameters();