From 519c2796e52ea933f6de5a490aee1f1ab826ea5e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 Jan 2016 22:54:36 +0300 Subject: Add support for custom NLS (without gettext). Add configure flag --enable-customnls Add empty directory in data/translations/manaplus for suctom translations (po files from /po directory) --- src/utils/translation/podict.cpp | 3 +++ src/utils/translation/podict.h | 3 +++ src/utils/translation/translationmanager.cpp | 8 ++++++++ src/utils/translation/translationmanager.h | 4 ++++ 4 files changed, 18 insertions(+) (limited to 'src/utils/translation') diff --git a/src/utils/translation/podict.cpp b/src/utils/translation/podict.cpp index 8aca50880..ba199a6d6 100644 --- a/src/utils/translation/podict.cpp +++ b/src/utils/translation/podict.cpp @@ -25,6 +25,9 @@ std::string empty; PoDict *translator = nullptr; +#ifdef ENABLE_CUSTOMNLS +PoDict *mainTranslator = nullptr; +#endif PoDict::PoDict(std::string lang) : mPoLines(), diff --git a/src/utils/translation/podict.h b/src/utils/translation/podict.h index 4153835bd..73948aeb4 100644 --- a/src/utils/translation/podict.h +++ b/src/utils/translation/podict.h @@ -61,5 +61,8 @@ class PoDict final }; extern PoDict *translator; +#ifdef ENABLE_CUSTOMNLS +extern PoDict *mainTranslator; +#endif #endif // UTILS_TRANSLATION_PODICT_H diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp index 01f38e57f..4fa233990 100644 --- a/src/utils/translation/translationmanager.cpp +++ b/src/utils/translation/translationmanager.cpp @@ -44,6 +44,14 @@ void TranslationManager::loadCurrentLang() translator = loadLang(getLang(), "help/", translator); } +#ifdef ENABLE_CUSTOMNLS +void TranslationManager::loadGettextLang() +{ + delete mainTranslator; + mainTranslator = loadLang(getLang(), "manaplus/"); +} +#endif + void TranslationManager::close() { delete2(translator); diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h index e6e56dd4a..e228b1e75 100644 --- a/src/utils/translation/translationmanager.h +++ b/src/utils/translation/translationmanager.h @@ -41,6 +41,10 @@ class TranslationManager final static void loadCurrentLang(); +#ifdef ENABLE_CUSTOMNLS + static void loadGettextLang(); +#endif + static bool translateFile(const std::string &fileName, PoDict *const dict, StringVect &lines); -- cgit v1.2.3-70-g09d2