Changed: For ingame help html files, use english files as fallback.
--HG-- branch : develop
This commit is contained in:
parent
06c0f6800c
commit
d8638fa42b
2 changed files with 50 additions and 9 deletions
|
@ -297,6 +297,49 @@ void CGroupQuickHelp::beginElement (uint element_number, const std::vector<bool>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ***************************************************************************
|
||||||
|
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)
|
void CGroupQuickHelp::browse (const char *url)
|
||||||
|
@ -307,12 +350,7 @@ void CGroupQuickHelp::browse (const char *url)
|
||||||
|
|
||||||
_IsQuickHelp = false;
|
_IsQuickHelp = false;
|
||||||
|
|
||||||
string completeURL = url;
|
string completeURL = getLanguageUrl(url, ClientCfg.getHtmlLanguageCode());
|
||||||
if (completeURL.substr(completeURL.size()-5, 5) == ".html")
|
|
||||||
{
|
|
||||||
completeURL = completeURL.substr(0, completeURL.size()-5); // Substract the ".html"
|
|
||||||
completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html";
|
|
||||||
}
|
|
||||||
|
|
||||||
CGroupHTML::browse (completeURL.c_str());
|
CGroupHTML::browse (completeURL.c_str());
|
||||||
}
|
}
|
||||||
|
@ -321,9 +359,7 @@ void CGroupQuickHelp::browse (const char *url)
|
||||||
|
|
||||||
std::string CGroupQuickHelp::home()
|
std::string CGroupQuickHelp::home()
|
||||||
{
|
{
|
||||||
string completeURL = Home;
|
string completeURL = getLanguageUrl(Home, ClientCfg.getHtmlLanguageCode());
|
||||||
completeURL = completeURL.substr(0, completeURL.size()-5); // Substract the ".html"
|
|
||||||
completeURL += "_" + ClientCfg.getHtmlLanguageCode() + ".html";
|
|
||||||
|
|
||||||
return completeURL;
|
return completeURL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,11 @@ private:
|
||||||
virtual void browse (const char *url);
|
virtual void browse (const char *url);
|
||||||
virtual std::string home();
|
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
|
// Init parsing value
|
||||||
void initParameters();
|
void initParameters();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue