diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 0eb643984e..19beae4734 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -24,12 +24,8 @@ #include "i18n/L10n.h" -#include -#include -#include -#include - #include "gui/GUIManager.h" +#include "lib/external_libraries/tinygettext.h" #include "lib/file/file_system.h" #include "lib/utf8.h" #include "ps/CLogger.h" @@ -37,11 +33,49 @@ #include "ps/Filesystem.h" #include "ps/GameSetup/GameSetup.h" -static Status ReloadChangedFileCB(void* param, const VfsPath& path) +#include +#include +#include +#include + +namespace +{ + +Status ReloadChangedFileCB(void* param, const VfsPath& path) { return static_cast(param)->ReloadChangedFile(path); } +/** + * Loads the specified content of a PO file into the specified dictionary. + * + * Used by LoadDictionaryForCurrentLocale() to add entries to the game + * translations @link dictionary. + * + * @param poContent Content of a PO file as a string. + * @param dictionary Dictionary where the entries from the PO file should be + * stored. + */ +void ReadPoIntoDictionary(const std::string& poContent, tinygettext::Dictionary* dictionary) +{ + try + { + std::istringstream inputStream(poContent); + tinygettext::POParser::parse("virtual PO file", inputStream, *dictionary); + } + catch (std::exception& e) + { + LOGERROR("[Localization] Exception while reading virtual PO file: %s", e.what()); + } +} + +} // anonymous namespace + +void L10n::DictionaryDeleter::operator()(tinygettext::Dictionary* dictionary) +{ + delete dictionary; +} + L10n::L10n() : m_Dictionary(new tinygettext::Dictionary()), currentLocaleIsOriginalGameLocale(false), useLongStrings(false) { @@ -518,19 +552,6 @@ void L10n::LoadListOfAvailableLocales() } } -void L10n::ReadPoIntoDictionary(const std::string& poContent, tinygettext::Dictionary* dictionary) const -{ - try - { - std::istringstream inputStream(poContent); - tinygettext::POParser::parse("virtual PO file", inputStream, *dictionary); - } - catch(std::exception& e) - { - LOGERROR("[Localization] Exception while reading virtual PO file: %s", e.what()); - } -} - icu::DateFormat* L10n::CreateDateTimeInstance(const L10n::DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale) const { switch(type) diff --git a/source/i18n/L10n.h b/source/i18n/L10n.h index 895b9385cc..532d9cfa62 100644 --- a/source/i18n/L10n.h +++ b/source/i18n/L10n.h @@ -25,7 +25,6 @@ #include "lib/code_annotation.h" #include "lib/external_libraries/icu.h" -#include "lib/external_libraries/tinygettext.h" #include "lib/file/vfs/vfs_path.h" #include "ps/Singleton.h" @@ -33,6 +32,11 @@ #include #include +namespace tinygettext +{ + class Dictionary; +} + #define g_L10n L10n::GetSingleton() /** @@ -475,6 +479,10 @@ public: Status ReloadChangedFile(const VfsPath& path); private: + struct DictionaryDeleter + { + void operator()(tinygettext::Dictionary* dictionary); + }; /** * Dictionary that contains the translations for the @@ -483,7 +491,7 @@ private: * * @sa LoadDictionaryForCurrentLocale() */ - std::unique_ptr m_Dictionary; + std::unique_ptr m_Dictionary; /** * Locale that the game is currently using. @@ -556,18 +564,6 @@ private: */ void LoadListOfAvailableLocales(); - /** - * Loads the specified content of a PO file into the specified dictionary. - * - * Used by LoadDictionaryForCurrentLocale() to add entries to the game - * translations @link dictionary. - * - * @param poContent Content of a PO file as a string. - * @param dictionary Dictionary where the entries from the PO file should be - * stored. - */ - void ReadPoIntoDictionary(const std::string& poContent, tinygettext::Dictionary* dictionary) const; - /** * Creates an ICU date formatted with the specified settings. *