summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/serverdialog.cpp7
-rw-r--r--src/utils/stringutils.cpp20
-rw-r--r--src/utils/stringutils.h2
3 files changed, 28 insertions, 1 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 98d9bbfee..59bdf9660 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -511,6 +511,9 @@ void ServerDialog::loadServers(bool addNew)
return;
}
+ const std::string lang = getLangShort();
+ const std::string description2 = "description_" + lang;
+
for_each_xml_child_node(serverNode, rootNode)
{
if (!xmlNameEqual(serverNode, "server"))
@@ -560,7 +563,9 @@ void ServerDialog::loadServers(bool addNew)
server.port = defaultPortForServerType(server.type);
}
}
- else if (xmlNameEqual(subNode, "description"))
+ else if ((xmlNameEqual(subNode, "description")
+ && server.description.empty()) || (!lang.empty()
+ && xmlNameEqual(subNode, description2.c_str())))
{
server.description = reinterpret_cast<const char*>(
subNode->xmlChildrenNode->content);
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index a5c0c471b..08bcac9e6 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -522,6 +522,26 @@ std::string getLangSimple()
return lang;
}
+std::string getLangShort()
+{
+ std::string lang = config.getValue("lang", "").c_str();
+ if (lang.empty())
+ {
+ char *lng = getenv("LANG");
+ if (!lng)
+ return "";
+ lang = lng;
+ }
+
+ int dot = lang.find(".");
+ if (dot != (signed)std::string::npos)
+ lang = lang.substr(0, dot);
+ dot = lang.find("_");
+ if (dot != (signed)std::string::npos)
+ return lang.substr(0, dot);
+ return lang;
+}
+
std::string packList(std::list<std::string> &list)
{
std::list<std::string>::const_iterator i = list.begin();
diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h
index 5cb726eef..0b22ef847 100644
--- a/src/utils/stringutils.h
+++ b/src/utils/stringutils.h
@@ -190,6 +190,8 @@ std::vector<std::string> getLang();
std::string getLangSimple();
+std::string getLangShort();
+
std::string packList(std::list<std::string> &list);
std::list<std::string> unpackList(const std::string &str);