summaryrefslogtreecommitdiff
path: root/src/utils/translation/translationmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-04-05 02:29:29 +0300
committerAndrei Karas <akaras@inbox.ru>2017-04-05 02:29:29 +0300
commitd8a530e299b4dd04c020ca3e3eeda7b12f89b69b (patch)
tree25cdf2254d6fd6eb2f8767f81bab58ff6dab844a /src/utils/translation/translationmanager.cpp
parent75c9723444581805ccbaafaa26109e5bee0d37c6 (diff)
downloadManaVerse-d8a530e299b4dd04c020ca3e3eeda7b12f89b69b.tar.gz
ManaVerse-d8a530e299b4dd04c020ca3e3eeda7b12f89b69b.tar.bz2
ManaVerse-d8a530e299b4dd04c020ca3e3eeda7b12f89b69b.tar.xz
ManaVerse-d8a530e299b4dd04c020ca3e3eeda7b12f89b69b.zip
Add reverse translation dictionary.
Diffstat (limited to 'src/utils/translation/translationmanager.cpp')
-rw-r--r--src/utils/translation/translationmanager.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp
index 3ab5dbb23..f64d8e612 100644
--- a/src/utils/translation/translationmanager.cpp
+++ b/src/utils/translation/translationmanager.cpp
@@ -44,6 +44,7 @@ void TranslationManager::loadCurrentLang()
translator = loadLang(getLang(), "");
translator = loadLang(getLang(), "help/", translator);
dictionary = loadLang(getLang(), "dict/");
+ reverseDictionary = reverseLang(dictionary);
}
#ifdef ENABLE_CUSTOMNLS
@@ -57,6 +58,8 @@ void TranslationManager::loadGettextLang()
void TranslationManager::close()
{
delete2(translator);
+ delete2(dictionary);
+ delete2(reverseDictionary);
}
PoDict *TranslationManager::loadLang(const LangVect &lang,
@@ -131,3 +134,13 @@ bool TranslationManager::translateFile(const std::string &fileName,
delete [] fileContents;
return true;
}
+
+PoDict *TranslationManager::reverseLang(const PoDict *const dict)
+{
+ PoDict *const revDict = new PoDict(dict->mLang);
+ FOR_EACH (PoMap::const_iterator, it, dict->mPoLines)
+ {
+ revDict->set((*it).second, (*it).first);
+ }
+ return revDict;
+}