Changeset View
Changeset View
Standalone View
Standalone View
source/i18n/scripting/JSInterface_L10n.h
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | namespace JSI_L10n | ||||
* | * | ||||
* This is a JavaScript interface to L10n::Translate(). | * This is a JavaScript interface to L10n::Translate(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param sourceString String to translate to the current locale. | * @param sourceString String to translate to the current locale. | ||||
* @return Translation of @p sourceString to the current locale, or | * @return Translation of @p sourceString to the current locale, or | ||||
* @p sourceString if there is no translation available. | * @p sourceString if there is no translation available. | ||||
*/ | */ | ||||
std::wstring Translate(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& sourceString); | std::wstring Translate(const std::wstring& sourceString); | ||||
Stan: I wonder if those shouldn't be CStrW. | |||||
/** | /** | ||||
* Returns the translation of the specified string to the | * Returns the translation of the specified string to the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink in the specified | * @link L10n::GetCurrentLocale() current locale@endlink in the specified | ||||
* context. | * context. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::TranslateWithContext(). | * This is a JavaScript interface to L10n::TranslateWithContext(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param context Context where the string is used. See | * @param context Context where the string is used. See | ||||
* http://www.gnu.org/software/gettext/manual/html_node/Contexts.html | * http://www.gnu.org/software/gettext/manual/html_node/Contexts.html | ||||
* @param sourceString String to translate to the current locale. | * @param sourceString String to translate to the current locale. | ||||
* @return Translation of @p sourceString to the current locale in the | * @return Translation of @p sourceString to the current locale in the | ||||
* specified @p context, or @p sourceString if there is no | * specified @p context, or @p sourceString if there is no | ||||
* translation available. | * translation available. | ||||
*/ | */ | ||||
std::wstring TranslateWithContext(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& context, const std::wstring& sourceString); | std::wstring TranslateWithContext(const std::string& context, const std::wstring& sourceString); | ||||
/** | /** | ||||
* Returns the translation of the specified string to the | * Returns the translation of the specified string to the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink based on the | * @link L10n::GetCurrentLocale() current locale@endlink based on the | ||||
* specified number. | * specified number. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::TranslatePlural(). | * This is a JavaScript interface to L10n::TranslatePlural(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param singularSourceString String to translate to the current locale, | * @param singularSourceString String to translate to the current locale, | ||||
* in English’ singular form. | * in English’ singular form. | ||||
* @param pluralSourceString String to translate to the current locale, in | * @param pluralSourceString String to translate to the current locale, in | ||||
* English’ plural form. | * English’ plural form. | ||||
* @param number Number that determines the required form of the translation | * @param number Number that determines the required form of the translation | ||||
* (or the English string if no translation is available). | * (or the English string if no translation is available). | ||||
* @return Translation of the source string to the current locale for the | * @return Translation of the source string to the current locale for the | ||||
* specified @p number, or either @p singularSourceString (if | * specified @p number, or either @p singularSourceString (if | ||||
* @p number is 1) or @p pluralSourceString (if @p number is not 1) | * @p number is 1) or @p pluralSourceString (if @p number is not 1) | ||||
* if there is no translation available. | * if there is no translation available. | ||||
*/ | */ | ||||
std::wstring TranslatePlural(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number); | std::wstring TranslatePlural(const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number); | ||||
/** | /** | ||||
* Returns the translation of the specified string to the | * Returns the translation of the specified string to the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink in the specified | * @link L10n::GetCurrentLocale() current locale@endlink in the specified | ||||
* context, based on the specified number. | * context, based on the specified number. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::TranslatePluralWithContext(). | * This is a JavaScript interface to L10n::TranslatePluralWithContext(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param context Context where the string is used. See | * @param context Context where the string is used. See | ||||
* http://www.gnu.org/software/gettext/manual/html_node/Contexts.html | * http://www.gnu.org/software/gettext/manual/html_node/Contexts.html | ||||
* @param singularSourceString String to translate to the current locale, | * @param singularSourceString String to translate to the current locale, | ||||
* in English’ singular form. | * in English’ singular form. | ||||
* @param pluralSourceString String to translate to the current locale, in | * @param pluralSourceString String to translate to the current locale, in | ||||
* English’ plural form. | * English’ plural form. | ||||
* @param number Number that determines the required form of the translation | * @param number Number that determines the required form of the translation | ||||
* (or the English string if no translation is available). * | * (or the English string if no translation is available). * | ||||
* @return Translation of the source string to the current locale in the | * @return Translation of the source string to the current locale in the | ||||
* specified @p context and for the specified @p number, or either | * specified @p context and for the specified @p number, or either | ||||
* @p singularSourceString (if @p number is 1) or | * @p singularSourceString (if @p number is 1) or | ||||
* @p pluralSourceString (if @p number is not 1) if there is no | * @p pluralSourceString (if @p number is not 1) if there is no | ||||
* translation available. | * translation available. | ||||
*/ | */ | ||||
std::wstring TranslatePluralWithContext(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& context, const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number); | std::wstring TranslatePluralWithContext(const std::string& context, const std::wstring& singularSourceString, const std::wstring& pluralSourceString, int number); | ||||
/** | /** | ||||
* Translates a text line by line to the | * Translates a text line by line to the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink. | * @link L10n::GetCurrentLocale() current locale@endlink. | ||||
* | * | ||||
* TranslateLines() is helpful when you need to translate a plain text file | * TranslateLines() is helpful when you need to translate a plain text file | ||||
* after you load it. | * after you load it. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::TranslateLines(). | * This is a JavaScript interface to L10n::TranslateLines(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param sourceString Text to translate to the current locale. | * @param sourceString Text to translate to the current locale. | ||||
* @return Line by line translation of @p sourceString to the current | * @return Line by line translation of @p sourceString to the current | ||||
* locale. Some of the lines in the returned text may be in English | * locale. Some of the lines in the returned text may be in English | ||||
* because there was not translation available for them. | * because there was not translation available for them. | ||||
*/ | */ | ||||
std::wstring TranslateLines(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& sourceString); | std::wstring TranslateLines(const std::wstring& sourceString); | ||||
/** | /** | ||||
* Translate each of the strings of a JavaScript array to the | * Translate each of the strings of a JavaScript array to the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink. | * @link L10n::GetCurrentLocale() current locale@endlink. | ||||
* | * | ||||
* This is a helper function that loops through the items of the input array | * This is a helper function that loops through the items of the input array | ||||
* and calls L10n::Translate() on each of them. | * and calls L10n::Translate() on each of them. | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param sourceArray JavaScript array of strings to translate to the | * @param sourceArray JavaScript array of strings to translate to the | ||||
* current locale. | * current locale. | ||||
* @return Item by item translation of @p sourceArray to the current locale. | * @return Item by item translation of @p sourceArray to the current locale. | ||||
* Some of the items in the returned array may be in English because | * Some of the items in the returned array may be in English because | ||||
* there was not translation available for them. | * there was not translation available for them. | ||||
*/ | */ | ||||
std::vector<std::wstring> TranslateArray(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::vector<std::wstring>& sourceArray); | std::vector<std::wstring> TranslateArray(const std::vector<std::wstring>& sourceArray); | ||||
/** | /** | ||||
* Returns the specified date converted to the local timezone using the specified date format. | * Returns the specified date converted to the local timezone using the specified date format. | ||||
* | * | ||||
* This is a JavaScript interface to | * This is a JavaScript interface to | ||||
* L10n::FormatMillisecondsIntoDateString(). | * L10n::FormatMillisecondsIntoDateString(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param milliseconds Date specified as a UNIX timestamp in milliseconds | * @param milliseconds Date specified as a UNIX timestamp in milliseconds | ||||
* (not seconds). If you have a JavaScript @c !Date object, you can | * (not seconds). If you have a JavaScript @c !Date object, you can | ||||
* use @c !Date.getTime() to obtain the UNIX time in milliseconds. | * use @c !Date.getTime() to obtain the UNIX time in milliseconds. | ||||
* @param formatString Date format string defined using ICU date formatting | * @param formatString Date format string defined using ICU date formatting | ||||
* symbols. Usually, you internationalize the format string and | * symbols. Usually, you internationalize the format string and | ||||
* get it translated before you pass it to | * get it translated before you pass it to | ||||
* FormatMillisecondsIntoDateString(). | * FormatMillisecondsIntoDateString(). | ||||
* @return String containing the specified date with the specified date | * @return String containing the specified date with the specified date | ||||
* format. | * format. | ||||
* | * | ||||
* @sa http://en.wikipedia.org/wiki/Unix_time | * @sa http://en.wikipedia.org/wiki/Unix_time | ||||
* @sa https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table | * @sa https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table | ||||
*/ | */ | ||||
std::wstring FormatMillisecondsIntoDateStringLocal(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), UDate milliseconds, const std::wstring& formatString); | std::wstring FormatMillisecondsIntoDateStringLocal(UDate milliseconds, const std::wstring& formatString); | ||||
/** | /** | ||||
* Returns the specified date in GMT using the specified date format. | * Returns the specified date in GMT using the specified date format. | ||||
* | * | ||||
* This is a JavaScript interface to | * This is a JavaScript interface to | ||||
* L10n::FormatMillisecondsIntoDateString(). | * L10n::FormatMillisecondsIntoDateString(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param milliseconds Date specified as a UNIX timestamp in milliseconds | * @param milliseconds Date specified as a UNIX timestamp in milliseconds | ||||
* (not seconds). If you have a JavaScript @c !Date object, you can | * (not seconds). If you have a JavaScript @c !Date object, you can | ||||
* use @c !Date.getTime() to obtain the UNIX time in milliseconds. | * use @c !Date.getTime() to obtain the UNIX time in milliseconds. | ||||
* @param formatString Date format string defined using ICU date formatting | * @param formatString Date format string defined using ICU date formatting | ||||
* symbols. Usually, you internationalize the format string and | * symbols. Usually, you internationalize the format string and | ||||
* get it translated before you pass it to | * get it translated before you pass it to | ||||
* FormatMillisecondsIntoDateString(). | * FormatMillisecondsIntoDateString(). | ||||
* @return String containing the specified date with the specified date | * @return String containing the specified date with the specified date | ||||
* format. | * format. | ||||
* | * | ||||
* @sa http://en.wikipedia.org/wiki/Unix_time | * @sa http://en.wikipedia.org/wiki/Unix_time | ||||
* @sa https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table | * @sa https://sites.google.com/site/icuprojectuserguide/formatparse/datetime?pli=1#TOC-Date-Field-Symbol-Table | ||||
*/ | */ | ||||
std::wstring FormatMillisecondsIntoDateStringGMT(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), UDate milliseconds, const std::wstring& formatString); | std::wstring FormatMillisecondsIntoDateStringGMT(UDate milliseconds, const std::wstring& formatString); | ||||
/** | /** | ||||
* Returns the specified floating-point number as a string, with the number | * Returns the specified floating-point number as a string, with the number | ||||
* formatted as a decimal number using the | * formatted as a decimal number using the | ||||
* @link L10n::GetCurrentLocale() current locale@endlink. | * @link L10n::GetCurrentLocale() current locale@endlink. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::FormatDecimalNumberIntoString(). | * This is a JavaScript interface to L10n::FormatDecimalNumberIntoString(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param number Number to format. | * @param number Number to format. | ||||
* @return Decimal number formatted using the current locale. | * @return Decimal number formatted using the current locale. | ||||
*/ | */ | ||||
std::wstring FormatDecimalNumberIntoString(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), double number); | std::wstring FormatDecimalNumberIntoString(double number); | ||||
/** | /** | ||||
* Returns an array of supported locale codes sorted alphabetically. | * Returns an array of supported locale codes sorted alphabetically. | ||||
* | * | ||||
* A locale code is a string such as "de" or "pt_BR". | * A locale code is a string such as "de" or "pt_BR". | ||||
* | * | ||||
* If yours is a development copy (the ‘config/dev.cfg’ file is found in the | * If yours is a development copy (the ‘config/dev.cfg’ file is found in the | ||||
* virtual filesystem), the output array may include the special “long” | * virtual filesystem), the output array may include the special “long” | ||||
* locale code. | * locale code. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetSupportedLocaleBaseNames(). | * This is a JavaScript interface to L10n::GetSupportedLocaleBaseNames(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @return Array of supported locale codes. | * @return Array of supported locale codes. | ||||
* | * | ||||
* @sa GetSupportedLocaleDisplayNames() | * @sa GetSupportedLocaleDisplayNames() | ||||
* @sa GetAllLocales() | * @sa GetAllLocales() | ||||
* @sa GetCurrentLocale() | * @sa GetCurrentLocale() | ||||
* | * | ||||
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | * @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | ||||
*/ | */ | ||||
std::vector<std::string> GetSupportedLocaleBaseNames(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)); | std::vector<std::string> GetSupportedLocaleBaseNames(); | ||||
/** | /** | ||||
* Returns an array of supported locale names sorted alphabetically by | * Returns an array of supported locale names sorted alphabetically by | ||||
* locale code. | * locale code. | ||||
* | * | ||||
* A locale code is a string such as "de" or "pt_BR". | * A locale code is a string such as "de" or "pt_BR". | ||||
* | * | ||||
* If yours is a development copy (the ‘config/dev.cfg’ file is found in the | * If yours is a development copy (the ‘config/dev.cfg’ file is found in the | ||||
* virtual filesystem), the output array may include the special “Long | * virtual filesystem), the output array may include the special “Long | ||||
* Strings” locale name. | * Strings” locale name. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetSupportedLocaleDisplayNames(). | * This is a JavaScript interface to L10n::GetSupportedLocaleDisplayNames(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @return Array of supported locale codes. | * @return Array of supported locale codes. | ||||
* | * | ||||
* @sa GetSupportedLocaleBaseNames() | * @sa GetSupportedLocaleBaseNames() | ||||
* | * | ||||
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | * @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | ||||
*/ | */ | ||||
std::vector<std::wstring> GetSupportedLocaleDisplayNames(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)); | std::vector<std::wstring> GetSupportedLocaleDisplayNames(); | ||||
/** | /** | ||||
* 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". | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetCurrentLocaleString(). | * This is a JavaScript interface to L10n::GetCurrentLocaleString(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* | * | ||||
* @sa GetSupportedLocaleBaseNames() | * @sa GetSupportedLocaleBaseNames() | ||||
* @sa GetAllLocales() | * @sa GetAllLocales() | ||||
* @sa ReevaluateCurrentLocaleAndReload() | * @sa ReevaluateCurrentLocaleAndReload() | ||||
*/ | */ | ||||
std::string GetCurrentLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)); | std::string GetCurrentLocale(); | ||||
/** | /** | ||||
* Returns an array of locale codes supported by ICU. | * Returns an array of locale codes supported by ICU. | ||||
* | * | ||||
* A locale code is a string such as "de" or "pt_BR". | * A locale code is a string such as "de" or "pt_BR". | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetAllLocales(). | * This is a JavaScript interface to L10n::GetAllLocales(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @return Array of supported locale codes. | * @return Array of supported locale codes. | ||||
* | * | ||||
* @sa GetSupportedLocaleBaseNames() | * @sa GetSupportedLocaleBaseNames() | ||||
* @sa GetCurrentLocale() | * @sa GetCurrentLocale() | ||||
* | * | ||||
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a073d70df8c9c8d119c0d42d70de24137 | * @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a073d70df8c9c8d119c0d42d70de24137 | ||||
*/ | */ | ||||
std::vector<std::string> GetAllLocales(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)); | std::vector<std::string> GetAllLocales(); | ||||
/** | /** | ||||
* Returns the code of the recommended locale for the current user that the | * Returns the code of the recommended locale for the current user that the | ||||
* game supports. | * game supports. | ||||
* | * | ||||
* “That the game supports” means both that a translation file is available | * “That the game supports” means both that a translation file is available | ||||
* for that locale and that the locale code is either supported by ICU or | * for that locale and that the locale code is either supported by ICU or | ||||
* the special “long” locale code. | * the special “long” locale code. | ||||
Show All 9 Lines | namespace JSI_L10n | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param configLocale Locale to check for support first. Pass an empty | * @param configLocale Locale to check for support first. Pass an empty | ||||
* string to check the system locale directly. | * string to check the system locale directly. | ||||
* @return Code of a locale that the game supports. | * @return Code of a locale that the game supports. | ||||
* | * | ||||
* @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | * @sa http://trac.wildfiregames.com/wiki/Implementation_of_Internationalization_and_Localization#LongStringsLocale | ||||
*/ | */ | ||||
std::string GetDictionaryLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& configLocale); | std::string GetDictionaryLocale(const std::string& configLocale); | ||||
/** | /** | ||||
* Returns an array of paths to files in the virtual filesystem that provide | * Returns an array of paths to files in the virtual filesystem that provide | ||||
* translations for the specified locale code. | * translations for the specified locale code. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetDictionariesForLocale(). | * This is a JavaScript interface to L10n::GetDictionariesForLocale(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale code. | * @param locale Locale code. | ||||
* @return Array of paths to files in the virtual filesystem that provide | * @return Array of paths to files in the virtual filesystem that provide | ||||
* translations for @p locale. | * translations for @p locale. | ||||
*/ | */ | ||||
std::vector<std::wstring> GetDictionariesForLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | std::vector<std::wstring> GetDictionariesForLocale(const std::string& locale); | ||||
/** | /** | ||||
* Returns the ISO-639 language code of the specified locale code. | * Returns the ISO-639 language code of the specified locale code. | ||||
* | * | ||||
* For example, if you specify the ‘en_US’ locate, it returns ‘en’. | * For example, if you specify the ‘en_US’ locate, it returns ‘en’. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetLocaleLanguage(). | * This is a JavaScript interface to L10n::GetLocaleLanguage(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale code. | * @param locale Locale code. | ||||
* @return Language code. | * @return Language code. | ||||
* | * | ||||
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#af36d821adced72a870d921ebadd0ca93 | * @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#af36d821adced72a870d921ebadd0ca93 | ||||
*/ | */ | ||||
std::string GetLocaleLanguage(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | std::string GetLocaleLanguage(const std::string& locale); | ||||
/** | /** | ||||
* Returns the programmatic code of the entire locale without keywords. | * Returns the programmatic code of the entire locale without keywords. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetLocaleBaseName(). | * This is a JavaScript interface to L10n::GetLocaleBaseName(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale code. | * @param locale Locale code. | ||||
* @return Locale code without keywords. | * @return Locale code without keywords. | ||||
* | * | ||||
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a4c1acbbdf95dc15599db5f322fa4c4d0 | * @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a4c1acbbdf95dc15599db5f322fa4c4d0 | ||||
*/ | */ | ||||
std::string GetLocaleBaseName(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | std::string GetLocaleBaseName(const std::string& locale); | ||||
/** | /** | ||||
* Returns the ISO-3166 country code of the specified locale code. | * Returns the ISO-3166 country code of the specified locale code. | ||||
* | * | ||||
* For example, if you specify the ‘en_US’ locate, it returns ‘US’. | * For example, if you specify the ‘en_US’ locate, it returns ‘US’. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetLocaleCountry(). | * This is a JavaScript interface to L10n::GetLocaleCountry(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale code. | * @param locale Locale code. | ||||
* @return Country code. | * @return Country code. | ||||
* | * | ||||
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#ae3f1fc415c00d4f0ab33288ceadccbf9 | * @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#ae3f1fc415c00d4f0ab33288ceadccbf9 | ||||
*/ | */ | ||||
std::string GetLocaleCountry(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | std::string GetLocaleCountry(const std::string& locale); | ||||
/** | /** | ||||
* Returns the ISO-15924 abbreviation script code of the specified locale code. | * Returns the ISO-15924 abbreviation script code of the specified locale code. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::GetLocaleScript(). | * This is a JavaScript interface to L10n::GetLocaleScript(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale code. | * @param locale Locale code. | ||||
* @return Script code. | * @return Script code. | ||||
* | * | ||||
* @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a5e0145a339d30794178a1412dcc55abe | * @sa http://www.icu-project.org/apiref/icu4c/classicu_1_1Locale.html#a5e0145a339d30794178a1412dcc55abe | ||||
*/ | */ | ||||
std::string GetLocaleScript(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | std::string GetLocaleScript(const std::string& locale); | ||||
std::wstring GetFallbackToAvailableDictLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | std::wstring GetFallbackToAvailableDictLocale(const std::string& locale); | ||||
/** | /** | ||||
* Returns @c true if the current locale is the special “Long Strings” | * Returns @c true if the current locale is the special “Long Strings” | ||||
* locale. It returns @c false otherwise. | * locale. It returns @c false otherwise. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::UseLongStrings(). | * This is a JavaScript interface to L10n::UseLongStrings(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. * | * @param pCxPrivate JavaScript context. * | ||||
* @return Whether the current locale is the special “Long Strings” | * @return Whether the current locale is the special “Long Strings” | ||||
* (@c true) or not (@c false). | * (@c true) or not (@c false). | ||||
*/ | */ | ||||
bool UseLongStrings(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)); | bool UseLongStrings(); | ||||
/** | /** | ||||
* Returns @c true if the locale is supported by both ICU and the game. It | * Returns @c true if the locale is supported by both ICU and the game. It | ||||
* returns @c false otherwise. | * returns @c false otherwise. | ||||
* | * | ||||
* It returns @c true if both of these conditions are true: | * It returns @c true if both of these conditions are true: | ||||
* 1. ICU has resources for that locale (which also ensures it’s a valid\n | * 1. ICU has resources for that locale (which also ensures it’s a valid\n | ||||
* locale string). | * locale string). | ||||
* 2. Either a dictionary for language_country or for language is\n | * 2. Either a dictionary for language_country or for language is\n | ||||
* available. | * available. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::ValidateLocale(const std::string&). | * This is a JavaScript interface to L10n::ValidateLocale(const std::string&). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale to check. | * @param locale Locale to check. | ||||
* @return Whether @p locale is supported by both ICU and the game (@c true) | * @return Whether @p locale is supported by both ICU and the game (@c true) | ||||
* or not (@c false). | * or not (@c false). | ||||
*/ | */ | ||||
bool ValidateLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | bool ValidateLocale(const std::string& locale); | ||||
/** | /** | ||||
* Saves the specified locale in the game configuration file. | * Saves the specified locale in the game configuration file. | ||||
* | * | ||||
* The next time that the game starts, the game uses the locale in the | * The next time that the game starts, the game uses the locale in the | ||||
* configuration file if there are translation files available for it. | * configuration file if there are translation files available for it. | ||||
* | * | ||||
* SaveLocale() checks the validity of the specified locale with | * SaveLocale() checks the validity of the specified locale with | ||||
* ValidateLocale(). If the specified locale is not valid, SaveLocale() | * ValidateLocale(). If the specified locale is not valid, SaveLocale() | ||||
* returns @c false and does not save the locale to the configuration file. | * returns @c false and does not save the locale to the configuration file. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::SaveLocale(). | * This is a JavaScript interface to L10n::SaveLocale(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* @param locale Locale to save to the configuration file. | * @param locale Locale to save to the configuration file. | ||||
* @return Whether the specified locale is valid (@c true) or not | * @return Whether the specified locale is valid (@c true) or not | ||||
* (@c false). | * (@c false). | ||||
*/ | */ | ||||
bool SaveLocale(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::string& locale); | bool SaveLocale(const std::string& locale); | ||||
/** | /** | ||||
* Determines the best, supported locale for the current user, makes it the | * Determines the best, supported locale for the current user, makes it the | ||||
* current game locale and reloads the translations dictionary with | * current game locale and reloads the translations dictionary with | ||||
* translations for that locale. | * translations for that locale. | ||||
* | * | ||||
* To determine the best locale, ReevaluateCurrentLocaleAndReload(): | * To determine the best locale, ReevaluateCurrentLocaleAndReload(): | ||||
* 1. Checks the user game configuration. | * 1. Checks the user game configuration. | ||||
* 2. If the locale is not defined there, it checks the system locale. | * 2. If the locale is not defined there, it checks the system locale. | ||||
* 3. If none of those locales are supported by the game, the default\n | * 3. If none of those locales are supported by the game, the default\n | ||||
* locale, ‘en_US’, is used. | * locale, ‘en_US’, is used. | ||||
* | * | ||||
* This is a JavaScript interface to L10n::ReevaluateCurrentLocaleAndReload(). | * This is a JavaScript interface to L10n::ReevaluateCurrentLocaleAndReload(). | ||||
* | * | ||||
* @param pCxPrivate JavaScript context. | * @param pCxPrivate JavaScript context. | ||||
* | * | ||||
* @sa GetCurrentLocale() | * @sa GetCurrentLocale() | ||||
*/ | */ | ||||
void ReevaluateCurrentLocaleAndReload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate)); | void ReevaluateCurrentLocaleAndReload(); | ||||
} | } | ||||
#endif // INCLUDED_JSINTERFACE_L10N | #endif // INCLUDED_JSINTERFACE_L10N |
Wildfire Games · Phabricator
I wonder if those shouldn't be CStrW.