Changeset View
Changeset View
Standalone View
Standalone View
source/i18n/L10n.h
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Returns the current locale. | * Returns the current locale. | ||||
* | * | ||||
* @sa GetCurrentLocaleString() | * @sa GetCurrentLocaleString() | ||||
* @sa GetSupportedLocaleBaseNames() | * @sa GetSupportedLocaleBaseNames() | ||||
* @sa GetAllLocales() | * @sa GetAllLocales() | ||||
* @sa ReevaluateCurrentLocaleAndReload() | * @sa ReevaluateCurrentLocaleAndReload() | ||||
*/ | */ | ||||
icu::Locale GetCurrentLocale() const; | const icu::Locale& GetCurrentLocale() const; | ||||
vladislavbelov: Might return `const icu::Locale&`. | |||||
/** | /** | ||||
* Returns the code of the current locale. | * Returns the code of the current locale. | ||||
* | * | ||||
* A locale code is a string such as "de" or "pt_BR". | * A locale code is a string such as "de" or "pt_BR". | ||||
* | * | ||||
* @sa GetCurrentLocale() | * @sa GetCurrentLocale() | ||||
* @sa GetSupportedLocaleBaseNames() | * @sa GetSupportedLocaleBaseNames() | ||||
▲ Show 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | private: | ||||
* also use GetCurrentLocaleString() to get the locale code of the current | * also use GetCurrentLocaleString() to get the locale code of the current | ||||
* locale. | * locale. | ||||
* | * | ||||
* To change the value of this variable: | * To change the value of this variable: | ||||
* 1. Save a new locale to the game configuration file with SaveLocale(). | * 1. Save a new locale to the game configuration file with SaveLocale(). | ||||
* 2. Reload the translation dictionary with\n | * 2. Reload the translation dictionary with\n | ||||
* ReevaluateCurrentLocaleAndReload(). | * ReevaluateCurrentLocaleAndReload(). | ||||
*/ | */ | ||||
icu::Locale currentLocale; | icu::Locale m_CurrentLocale; | ||||
/** | /** | ||||
* Vector with the locales that the game supports. | * Vector with the locales that the game supports. | ||||
* | * | ||||
* The list of available locales is calculated when the game starts. Call | * The list of available locales is calculated when the game starts. Call | ||||
* LoadListOfAvailableLocales() to refresh the list. | * LoadListOfAvailableLocales() to refresh the list. | ||||
* | * | ||||
* @sa GetSupportedLocaleBaseNames() | * @sa GetSupportedLocaleBaseNames() | ||||
* @sa GetSupportedLocaleDisplayNames() | * @sa GetSupportedLocaleDisplayNames() | ||||
*/ | */ | ||||
std::vector<std::unique_ptr<icu::Locale>> availableLocales; | const std::vector<icu::Locale> m_AvailableLocales; | ||||
Done Inline ActionsI suggest to fix the naming as well m_*, here and surroundings. vladislavbelov: I suggest to fix the naming as well `m_*`, here and surroundings. | |||||
/** | /** | ||||
* Whether the game is using the default game locale (@c true), 'en_US', or | * Whether the game is using the default game locale (@c true), 'en_US', or | ||||
* not (@c false). | * not (@c false). | ||||
* | * | ||||
* This variable is used in the L10n implementation for performance reasons. | * This variable is used in the L10n implementation for performance reasons. | ||||
* Many localization steps can be skipped when this variable is @c true. | * Many localization steps can be skipped when this variable is @c true. | ||||
*/ | */ | ||||
bool currentLocaleIsOriginalGameLocale; | bool m_CurrentLocaleIsOriginalGameLocale{false}; | ||||
/** | /** | ||||
* Whether the game is using the special game locale with the longest | * Whether the game is using the special game locale with the longest | ||||
* strings of each translation (@c true) or not (@c false). | * strings of each translation (@c true) or not (@c false). | ||||
* | * | ||||
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | * @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | ||||
*/ | */ | ||||
bool useLongStrings; | bool m_UseLongStrings{false}; | ||||
/** | /** | ||||
* Loads the translation files for the | * Loads the translation files for the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink. | * @link L10n::GetCurrentLocale() current locale@endlink. | ||||
* | * | ||||
* This method loads every file in the 'l10n' folder of the game virtual | * This method loads every file in the 'l10n' folder of the game virtual | ||||
* filesystem that is prefixed with the code of the current locale followed | * filesystem that is prefixed with the code of the current locale followed | ||||
* by a dot. | * by a dot. | ||||
* | * | ||||
* For example, if the code of the current locale code is 'de', | * For example, if the code of the current locale code is 'de', | ||||
* LoadDictionaryForCurrentLocale() loads the 'l10n/de.engine.po' and | * LoadDictionaryForCurrentLocale() loads the 'l10n/de.engine.po' and | ||||
* 'l10n/de.public.po' translation files. | * 'l10n/de.public.po' translation files. | ||||
* | * | ||||
* @sa dictionary | * @sa dictionary | ||||
* @sa ReadPoIntoDictionary() | * @sa ReadPoIntoDictionary() | ||||
*/ | */ | ||||
void LoadDictionaryForCurrentLocale(); | void LoadDictionaryForCurrentLocale(); | ||||
/** | |||||
* Determines the list of locales that the game supports. | |||||
* | |||||
* LoadListOfAvailableLocales() checks the locale codes of the translation | |||||
* files in the 'l10n' folder of the virtual filesystem. If it finds a | |||||
* translation file prefixed with a locale code followed by a dot, it | |||||
* determines that the game supports that locale. | |||||
* | |||||
* @sa availableLocales | |||||
*/ | |||||
void LoadListOfAvailableLocales(); | |||||
}; | }; | ||||
#endif // INCLUDED_L10N | #endif // INCLUDED_L10N |
Wildfire Games · Phabricator
Might return const icu::Locale&.