summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/utils/translation/podict.cpp1
-rw-r--r--src/utils/translation/podict.h2
-rw-r--r--src/utils/translation/translationmanager.cpp13
-rw-r--r--src/utils/translation/translationmanager.h1
4 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp
index 1903227f0..37b1b2fe8 100644
--- a/src/utils/translation/podict.cpp
+++ b/src/utils/translation/podict.cpp
@@ -26,6 +26,7 @@ std::string empty;
PoDict *translator = nullptr;
PoDict *dictionary = nullptr;
+PoDict *reverseDictionary = nullptr;
#ifdef ENABLE_CUSTOMNLS
PoDict *mainTranslator = nullptr;
#endif // ENABLE_CUSTOMNLS
diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h
index 7aefe842c..a8b18bba4 100644
--- a/src/utils/translation/podict.h
+++ b/src/utils/translation/podict.h
@@ -45,6 +45,7 @@ class PoDict final
protected:
#endif // UNITTESTS
friend class PoParser;
+ friend class TranslationManager;
PoMap *getMap()
{ return &mPoLines; }
@@ -62,6 +63,7 @@ class PoDict final
extern PoDict *translator;
extern PoDict *dictionary;
+extern PoDict *reverseDictionary;
#ifdef ENABLE_CUSTOMNLS
extern PoDict *mainTranslator;
#endif // ENABLE_CUSTOMNLS
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;
+}
diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h
index 7230649e9..81ac4fda7 100644
--- a/src/utils/translation/translationmanager.h
+++ b/src/utils/translation/translationmanager.h
@@ -50,6 +50,7 @@ class TranslationManager final
static bool translateFile(const std::string &fileName,
PoDict *const dict,
StringVect &lines);
+ static PoDict *reverseLang(const PoDict *const dict);
};
#endif // UTILS_TRANSLATION_TRANSLATIONMANAGER_H