summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/helpwindow.cpp11
-rw-r--r--src/utils/stringutils.cpp16
-rw-r--r--src/utils/stringutils.h3
3 files changed, 20 insertions, 10 deletions
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index e366712e7..e31782b8b 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -98,18 +98,23 @@ void HelpWindow::loadHelp(const std::string &helpFile)
void HelpWindow::loadFile(const std::string &file)
{
- const std::string lang = getLang();
+ const std::vector<std::string> langs = getLang();
ResourceManager *resman = ResourceManager::getInstance();
std::string helpPath = branding.getStringValue("helpPath");
if (helpPath.empty())
helpPath = paths.getStringValue("help");
std::vector<std::string> lines;
- if (!lang.empty())
+ if (!langs.empty())
{
- const std::string name = helpPath + lang + "/" + file + ".txt";
+ std::string name = helpPath + langs[0] + "/" + file + ".txt";
if (resman->exists(name))
lines = resman->loadTextFile(name);
+ if (lines.empty() && langs.size() > 1)
+ {
+ name = helpPath + langs[1] + "/" + file + ".txt";
+ lines = resman->loadTextFile(name);
+ }
}
if (lines.empty())
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index 8ae155bf7..ea2d18276 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -440,16 +440,20 @@ std::string combineDye2(std::string file, std::string dye)
}
}
-std::string getLang()
+std::vector<std::string> getLang()
{
+ std::vector<std::string> langs;
char *lng = getenv("LANG");
if (!lng)
- return "";
+ return langs;
std::string lang(lng);
int dot = lang.find(".");
- if (dot == (signed)std::string::npos)
- return lang;
-
- return lang.substr(0, dot);
+ if (dot != (signed)std::string::npos)
+ lang = lang.substr(0, dot);
+ langs.push_back(lang);
+ dot = lang.find("_");
+ if (dot != (signed)std::string::npos)
+ langs.push_back(lang.substr(0, dot));
+ return langs;
} \ No newline at end of file
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 83773bd72..f0dbf0bd9 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -27,6 +27,7 @@
#include <sstream>
#include <list>
#include <set>
+#include <vector>
/**
* Trims spaces off the end and the beginning of the given string.
@@ -177,6 +178,6 @@ std::string combineDye(std::string file, std::string dye);
std::string combineDye2(std::string file, std::string dye);
-std::string getLang();
+std::vector<std::string> getLang();
#endif // UTILS_STRINGUTILS_H