40#define g_L10n L10n::GetSingleton()
128 bool SaveLocale(
const std::string& localeCode)
const;
130 bool SaveLocale(
const icu::Locale& locale)
const;
280 void GetDictionaryLocale(
const std::string& configLocaleString, icu::Locale& outLocale)
const;
323 std::string
Translate(
const std::string& sourceString)
const;
337 std::string
TranslateWithContext(
const std::string& context,
const std::string& sourceString)
const;
355 std::string
TranslatePlural(
const std::string& singularSourceString,
const std::string& pluralSourceString,
int number)
const;
376 std::string
TranslatePluralWithContext(
const std::string& context,
const std::string& singularSourceString,
const std::string& pluralSourceString,
int number)
const;
390 std::string
TranslateLines(
const std::string& sourceString)
const;
408 UDate
ParseDateTime(
const std::string& dateTimeString,
const std::string& dateTimeFormat,
const icu::Locale& locale)
const;
Singleton for internationalization and localization.
Definition: L10n.h:48
std::string GetDictionaryLocale(const std::string &configLocaleString) const
Returns the code of the recommended locale for the current user that the game supports.
Definition: L10n.cpp:258
UDate ParseDateTime(const std::string &dateTimeString, const std::string &dateTimeFormat, const icu::Locale &locale) const
Parses the date in the input string using the specified date format, and returns the parsed date as a...
Definition: L10n.cpp:445
std::string LocalizeDateTime(const UDate dateTime, const DateTimeType &type, const icu::DateFormat::EStyle &style) const
Returns the specified date using the specified date format.
Definition: L10n.cpp:455
std::string FormatDecimalNumberIntoString(double number) const
Returns the specified floating-point number as a string, with the number formatted as a decimal numbe...
Definition: L10n.cpp:497
L10n()
Creates an instance of L10n.
Definition: L10n.cpp:139
std::string Translate(const std::string &sourceString) const
Returns the translation of the specified string to the current locale.
Definition: L10n.cpp:391
std::string GetLocaleLanguage(const std::string &locale) const
Returns the ISO-639 language code of the specified locale code.
Definition: L10n.cpp:367
icu::Locale m_CurrentLocale
Locale that the game is currently using.
Definition: L10n.h:504
DateTimeType
Types of dates.
Definition: L10n.h:72
@ Date
Only date.
Definition: L10n.h:74
@ DateTime
Both date and time.
Definition: L10n.h:73
@ Time
Only time.
Definition: L10n.h:75
std::string GetLocaleScript(const std::string &locale) const
Returns the ISO-15924 abbreviation script code of the specified locale code.
Definition: L10n.cpp:385
bool m_UseLongStrings
Whether the game is using the special game locale with the longest strings of each translation (true)...
Definition: L10n.h:532
std::string TranslatePlural(const std::string &singularSourceString, const std::string &pluralSourceString, int number) const
Returns the translation of the specified string to the current locale based on the specified number.
Definition: L10n.cpp:407
std::vector< icu::Locale > m_AvailableLocales
Vector with the locales that the game supports.
Definition: L10n.h:515
std::string TranslateLines(const std::string &sourceString) const
Translates a text line by line to the current locale.
Definition: L10n.cpp:429
bool SaveLocale(const std::string &localeCode) const
Saves the specified locale in the game configuration file.
Definition: L10n.cpp:171
std::vector< std::wstring > GetDictionariesForLocale(const std::string &locale) const
Returns an array of paths to files in the virtual filesystem that provide translations for the specif...
Definition: L10n.cpp:206
bool UseLongStrings() const
Returns true if the current locale is the special "Long Strings" locale.
Definition: L10n.cpp:321
const icu::Locale & GetCurrentLocale() const
Returns the current locale.
Definition: L10n.cpp:166
std::string GetCurrentLocaleString() const
Returns the code of the current locale.
Definition: L10n.cpp:362
std::string TranslatePluralWithContext(const std::string &context, const std::string &singularSourceString, const std::string &pluralSourceString, int number) const
Returns the translation of the specified string to the current locale in the specified context,...
Definition: L10n.cpp:418
~L10n()
Handles the destruction of L10n.
Definition: L10n.cpp:161
bool ValidateLocale(const icu::Locale &locale) const
Returns true if the locale is supported by both ICU and the game.
Definition: L10n.cpp:198
std::string GetLocaleBaseName(const std::string &locale) const
Returns the programmatic code of the entire locale without keywords.
Definition: L10n.cpp:373
std::vector< std::wstring > GetSupportedLocaleDisplayNames() const
Returns an array of supported locale names sorted alphabetically by locale code.
Definition: L10n.cpp:338
std::string FormatMillisecondsIntoDateString(const UDate milliseconds, const std::string &formatString, bool useLocalTimezone) const
Returns the specified date using the specified date format.
Definition: L10n.cpp:470
Status ReloadChangedFile(const VfsPath &path)
Loads path into the dictionary if it is a translation file of the current locale.
Definition: L10n.cpp:522
void LoadDictionaryForCurrentLocale()
Loads the translation files for the current locale.
Definition: L10n.cpp:562
std::vector< std::string > GetAllLocales() const
Returns a vector of locale codes supported by ICU.
Definition: L10n.cpp:310
std::unique_ptr< tinygettext::Dictionary > m_Dictionary
Dictionary that contains the translations for the current locale and the matching English strings,...
Definition: L10n.h:490
std::wstring GetFallbackToAvailableDictLocale(const icu::Locale &locale) const
Definition: L10n.cpp:225
void ReevaluateCurrentLocaleAndReload()
Determines the best, supported locale for the current user, makes it the current game locale and relo...
Definition: L10n.cpp:288
bool m_CurrentLocaleIsOriginalGameLocale
Whether the game is using the default game locale (true), 'en_US', or not (false).
Definition: L10n.h:524
std::string TranslateWithContext(const std::string &context, const std::string &sourceString) const
Returns the translation of the specified string to the current locale in the specified context.
Definition: L10n.cpp:399
std::vector< std::string > GetSupportedLocaleBaseNames() const
Returns an array of supported locale codes sorted alphabetically.
Definition: L10n.cpp:326
VfsPath LocalizePath(const VfsPath &sourcePath) const
Returns the localized version of the specified path if there is one for the current locale.
Definition: L10n.cpp:512
std::string GetLocaleCountry(const std::string &locale) const
Returns the ISO-3166 country code of the specified locale code.
Definition: L10n.cpp:379
Template base class for singletons.
Definition: Singleton.h:34
i64 Status
Error handling system.
Definition: status.h:173