summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/langs.cpp25
-rw-r--r--src/utils/langs.h2
-rw-r--r--src/utils/translation/podict.cpp5
-rw-r--r--src/utils/translation/podict.h2
-rw-r--r--src/utils/translation/translationmanager.cpp8
-rw-r--r--src/utils/translation/translationmanager.h2
6 files changed, 43 insertions, 1 deletions
diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp
index 41545ac52..8aa452077 100644
--- a/src/utils/langs.cpp
+++ b/src/utils/langs.cpp
@@ -20,8 +20,16 @@
#include "utils/langs.h"
+#include "logger.h"
+
#include "configuration.h"
+#ifndef DYECMD
+#include "being/playerinfo.h"
+
+#include "resources/db/languagedb.h"
+#endif // DYECMD
+
#include "debug.h"
static const char *getLangName()
@@ -58,6 +66,23 @@ LangVect getLang()
return langs;
}
+LangVect getServerLang()
+{
+ LangVect langs;
+#ifndef DYECMD
+ const int id = PlayerInfo::getServerLanguage();
+ std::string lang = LanguageDb::getPo(id);
+ if (lang.empty())
+ return langs;
+ langs.push_back(lang);
+ const size_t idx = lang.find('_');
+ if (idx != std::string::npos)
+ langs.push_back(lang.substr(0, idx));
+#endif // DYECMD
+
+ return langs;
+}
+
std::string getLangSimple()
{
const std::string lang = config.getStringValue("lang");
diff --git a/src/utils/langs.h b/src/utils/langs.h
index dfbe65995..902dcf264 100644
--- a/src/utils/langs.h
+++ b/src/utils/langs.h
@@ -31,6 +31,8 @@ typedef LangVect::const_iterator LangIter;
LangVect getLang() A_WARN_UNUSED;
+LangVect getServerLang() A_WARN_UNUSED;
+
std::string getLangSimple() A_WARN_UNUSED;
std::string getLangShort() A_WARN_UNUSED;
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
index 37b1b2fe8..56fd42467 100644
--- a/src/utils/translation/podict.cpp
+++ b/src/utils/translation/podict.cpp
@@ -54,3 +54,8 @@ const char *PoDict::getChar(const char *const str)
return str;
return mPoLines[str].c_str();
}
+
+bool PoDict::haveStr(const std::string &str) const
+{
+ return mPoLines.find(str) != mPoLines.end();
+}
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
index a8b18bba4..d40aa1499 100644
--- a/src/utils/translation/podict.h
+++ b/src/utils/translation/podict.h
@@ -41,6 +41,8 @@ class PoDict final
const char *getChar(const char *const str);
+ bool haveStr(const std::string &str) const;
+
#ifndef UNITTESTS
protected:
#endif // UNITTESTS
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index f64d8e612..808ad5f2f 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -43,7 +43,13 @@ void TranslationManager::loadCurrentLang()
delete translator;
translator = loadLang(getLang(), "");
translator = loadLang(getLang(), "help/", translator);
- dictionary = loadLang(getLang(), "dict/");
+}
+
+void TranslationManager::loadDictionaryLang()
+{
+ delete dictionary;
+ delete reverseDictionary;
+ dictionary = loadLang(getServerLang(), "dict/");
reverseDictionary = reverseLang(dictionary);
}
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
index 81ac4fda7..088d97449 100644
--- a/src/utils/translation/translationmanager.h
+++ b/src/utils/translation/translationmanager.h
@@ -43,6 +43,8 @@ class TranslationManager final
static void loadCurrentLang();
+ static void loadDictionaryLang();
+
#ifdef ENABLE_CUSTOMNLS
static void loadGettextLang();
#endif // ENABLE_CUSTOMNLS