summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-02 17:36:06 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-02 17:36:06 +0300
commitadee4beacfb6865233c220e060697627d358bdb1 (patch)
treefc2133651606ab7f1879c0724810c71f1aae950c /src/utils
parent25a203cc7117ab67d3809f24b5fdd23a3653ef99 (diff)
downloadmv-adee4beacfb6865233c220e060697627d358bdb1.tar.gz
mv-adee4beacfb6865233c220e060697627d358bdb1.tar.bz2
mv-adee4beacfb6865233c220e060697627d358bdb1.tar.xz
mv-adee4beacfb6865233c220e060697627d358bdb1.zip
Use translation for server descriptions in server list.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/stringutils.cpp20
-rw-r--r--src/utils/stringutils.h2
2 files changed, 22 insertions, 0 deletions
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);