From 4d58b0729ef5c8063c43acba8a226eb47ee75aab Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Fri, 12 Mar 2021 09:11:22 +0000 Subject: [PATCH] Moves CreateDateTimeInstance from the public L10n header to its implementation. This was SVN commit r25042. --- source/i18n/L10n.cpp | 43 +++++++++++++++++++++++++++---------------- source/i18n/L10n.h | 20 ++++---------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/source/i18n/L10n.cpp b/source/i18n/L10n.cpp index 19beae4734..c49ee6deb5 100644 --- a/source/i18n/L10n.cpp +++ b/source/i18n/L10n.cpp @@ -69,6 +69,33 @@ void ReadPoIntoDictionary(const std::string& poContent, tinygettext::Dictionary* } } +/** + * Creates an ICU date formatted with the specified settings. + * + * @param type Whether formatted dates must show both the date and the time, + * only the date or only the time. + * @param style ICU style to format dates by default. + * @param locale Locale that the date formatter should use to parse strings. + * It has no relevance for date formatting, only matters for date + * parsing. + * @return ICU date formatter. + */ +icu::DateFormat* CreateDateTimeInstance(const L10n::DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale) +{ + switch (type) + { + case L10n::Date: + return icu::SimpleDateFormat::createDateInstance(style, locale); + + case L10n::Time: + return icu::SimpleDateFormat::createTimeInstance(style, locale); + + case L10n::DateTime: + default: + return icu::SimpleDateFormat::createDateTimeInstance(style, style, locale); + } +} + } // anonymous namespace void L10n::DictionaryDeleter::operator()(tinygettext::Dictionary* dictionary) @@ -551,19 +578,3 @@ void L10n::LoadListOfAvailableLocales() availableLocales.push_back(std::move(locale)); } } - -icu::DateFormat* L10n::CreateDateTimeInstance(const L10n::DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale) const -{ - switch(type) - { - case Date: - return icu::SimpleDateFormat::createDateInstance(style, locale); - - case Time: - return icu::SimpleDateFormat::createTimeInstance(style, locale); - - case DateTime: - default: - return icu::SimpleDateFormat::createDateTimeInstance(style, style, locale); - } -} diff --git a/source/i18n/L10n.h b/source/i18n/L10n.h index 532d9cfa62..e87b2a811c 100644 --- a/source/i18n/L10n.h +++ b/source/i18n/L10n.h @@ -34,7 +34,7 @@ namespace tinygettext { - class Dictionary; +class Dictionary; } #define g_L10n L10n::GetSingleton() @@ -56,7 +56,7 @@ public: L10n(); /** - * Handles the descruction of L10n. + * Handles the destruction of L10n. * * Never destroy the L10n singleton manually. It must run as long as the * game runs, and it is destroyed automatically when you quit the game. @@ -68,7 +68,8 @@ public: * * @sa LocalizeDateTime() */ - enum DateTimeType { + enum DateTimeType + { DateTime, ///< Both date and time. Date, ///< Only date. Time ///< Only time. @@ -563,19 +564,6 @@ private: * @sa availableLocales */ void LoadListOfAvailableLocales(); - - /** - * Creates an ICU date formatted with the specified settings. - * - * @param type Whether formatted dates must show both the date and the time, - * only the date or only the time. - * @param style ICU style to format dates by default. - * @param locale Locale that the date formatter should use to parse strings. - * It has no relevance for date formatting, only matters for date - * parsing. - * @return ICU date formatter. - */ - icu::DateFormat* CreateDateTimeInstance(const DateTimeType& type, const icu::DateFormat::EStyle& style, const icu::Locale& locale) const; }; #endif // INCLUDED_L10N