summaryrefslogtreecommitdiff
path: root/src/utils/stringutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/stringutils.cpp')
-rw-r--r--src/utils/stringutils.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp
index b855e3b04..08bcac9e6 100644
--- a/src/utils/stringutils.cpp
+++ b/src/utils/stringutils.cpp
@@ -509,6 +509,39 @@ std::vector<std::string> getLang()
return langs;
}
+std::string getLangSimple()
+{
+ std::string lang = config.getValue("lang", "").c_str();
+ if (lang.empty())
+ {
+ char *lng = getenv("LANG");
+ if (!lng)
+ return "";
+ return lng;
+ }
+ 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();
@@ -541,6 +574,9 @@ std::string stringToHexPath(const std::string &str)
void deleteCharLeft(std::string &str, unsigned *pos)
{
+ if (!pos)
+ return;
+
while (*pos > 0)
{
(*pos)--;