Namespaces | |
| namespace | detail |
Functions | |
| constexpr auto | translate_noop (const char *str) noexcept |
| special no-op inline functions to mark string literal as translatable | |
| constexpr auto | translate_noop (const char *ctx, const char *str) noexcept |
| constexpr auto | translate_noop (const char *single, const char *plural, std::int64_t n) noexcept |
| constexpr auto | translate_noop (const char *ctx, const char *single, const char *plural, std::int64_t n) noexcept |
| std::string | translate (std::string_view msg, LocaleDomainId domainId=defaultDomain) |
| Translates a message using the active locale. | |
| std::string | translate (std::string_view context, std::string_view msg, LocaleDomainId domainId=defaultDomain) |
| Translates a message in context using the active locale. | |
| std::string | translate (std::string_view single, std::string_view plural, std::int64_t n, LocaleDomainId domainId=defaultDomain) |
| Translates a plural message form using the active locale. | |
| std::string | translate (std::string_view context, std::string_view single, std::string_view plural, std::int64_t n, LocaleDomainId domainId=defaultDomain) |
| Translates a plural message form in context using the active locale. | |
| std::vector< std::string > | translateAll (const std::vector< std::string > &items, LocaleDomainId domainId=defaultDomain) |
| Translates all strings in a vector using the active locale. | |
| std::vector< std::string > | translateAll (const char *context, const std::vector< std::string > &items, LocaleDomainId domainId=defaultDomain) |
| Translates all strings in a vector with context using the active locale. | |
| const std::locale & | get () |
| Returns the active locale. | |
| const std::string & | getName () |
| Returns the active locale's name. | |
| const std::locale & | set (const std::string &localeName) |
| Loads and sets the active locale by its name. UTF-8 is always used as an encoding. | |
| boost::signals2::connection | onChanged (const std::function< void(const std::string &)> &cb) |
| Connects to a signal emitted every time the active locale is changed. | |
| std::vector< std::string > | getAvailableLocales () |
| Returns the list of the names of locales with available .mo files. "en" is always included as the default locale. The returned list is always sorted alphabetically. | |
| void | addCatalogPath (const std::filesystem::path &path) |
| Adds a path to .mo files. The path is expected to have the following directory structure: <locale name>/LC_MESSAGES/<domain name>.mo The active locale is reloaded on every call. | |
| LocaleDomainId | addDomain (const char *domainName, bool generic=false) |
| Adds a new domain. The active locale is reloaded on every call. | |
| LocaleDomainId | addDomain (const std::string &domainName, bool generic=false) |
| Adds a new domain. The active locale is reloaded on every call. | |
| LocaleDomainId | findDomain (const char *domainName) |
| Find an id for the given domain that can be passed to the translate functions. | |
| LocaleDomainId | findDomain (const std::string &domainName) |
| Find an id for the given domain that can be passed to the translate functions. | |
| const std::vector< LocaleDomainId > & | getGenericDomains () |
| Returns the list of domains used for cross-domain translations. Cross-domain translations are used for extensions from external plugins, e.g. custom check boxes for RibbonMenu. | |
| std::string | getDisplayName (const std::string &localeName) |
| Returns a display name for the given locale. | |
| void | setDisplayName (const std::string &localeName, const std::string &displayName) |
| Adds or updates a display name for the given locale. | |
| std::vector< std::string > | getSystemLocales () |
| Returns a list of system locales. The first one in the list is always the active system locale. | |
Variables | |
| constexpr LocaleDomainId | defaultDomain { 0 } |
| Locale domain internal identifier for MeshLib's own translations. | |
| constexpr LocaleDomainId | genericDomain { -2 } |
| Locale domain internal identifier for cross-domain translations. | |
| void MR::Locale::addCatalogPath | ( | const std::filesystem::path & | path | ) |
Adds a path to .mo files. The path is expected to have the following directory structure: <locale name>/LC_MESSAGES/<domain name>.mo The active locale is reloaded on every call.
| LocaleDomainId MR::Locale::addDomain | ( | const char * | domainName, |
| bool | generic = false ) |
Adds a new domain. The active locale is reloaded on every call.
| generic | - whether the domain is generic, i.e. should be used for cross-domain translations (false by default). |
| LocaleDomainId MR::Locale::addDomain | ( | const std::string & | domainName, |
| bool | generic = false ) |
Adds a new domain. The active locale is reloaded on every call.
| generic | - whether the domain is generic, i.e. should be used for cross-domain translations (false by default). |
| LocaleDomainId MR::Locale::findDomain | ( | const char * | domainName | ) |
Find an id for the given domain that can be passed to the translate functions.
| LocaleDomainId MR::Locale::findDomain | ( | const std::string & | domainName | ) |
Find an id for the given domain that can be passed to the translate functions.
| const std::locale & MR::Locale::get | ( | ) |
Returns the active locale.
| std::vector< std::string > MR::Locale::getAvailableLocales | ( | ) |
Returns the list of the names of locales with available .mo files. "en" is always included as the default locale. The returned list is always sorted alphabetically.
| std::string MR::Locale::getDisplayName | ( | const std::string & | localeName | ) |
Returns a display name for the given locale.
| const std::vector< LocaleDomainId > & MR::Locale::getGenericDomains | ( | ) |
Returns the list of domains used for cross-domain translations. Cross-domain translations are used for extensions from external plugins, e.g. custom check boxes for RibbonMenu.
| const std::string & MR::Locale::getName | ( | ) |
Returns the active locale's name.
| std::vector< std::string > MR::Locale::getSystemLocales | ( | ) |
Returns a list of system locales. The first one in the list is always the active system locale.
| boost::signals2::connection MR::Locale::onChanged | ( | const std::function< void(const std::string &)> & | cb | ) |
Connects to a signal emitted every time the active locale is changed.
| const std::locale & MR::Locale::set | ( | const std::string & | localeName | ) |
Loads and sets the active locale by its name. UTF-8 is always used as an encoding.
| void MR::Locale::setDisplayName | ( | const std::string & | localeName, |
| const std::string & | displayName ) |
Adds or updates a display name for the given locale.
| std::string MR::Locale::translate | ( | std::string_view | context, |
| std::string_view | msg, | ||
| LocaleDomainId | domainId = defaultDomain ) |
Translates a message in context using the active locale.
| std::string MR::Locale::translate | ( | std::string_view | context, |
| std::string_view | single, | ||
| std::string_view | plural, | ||
| std::int64_t | n, | ||
| LocaleDomainId | domainId = defaultDomain ) |
Translates a plural message form in context using the active locale.
| std::string MR::Locale::translate | ( | std::string_view | msg, |
| LocaleDomainId | domainId = defaultDomain ) |
Translates a message using the active locale.
| std::string MR::Locale::translate | ( | std::string_view | single, |
| std::string_view | plural, | ||
| std::int64_t | n, | ||
| LocaleDomainId | domainId = defaultDomain ) |
Translates a plural message form using the active locale.
|
inline |
Translates all strings in a vector with context using the active locale.
|
inline |
Translates all strings in a vector using the active locale.
|
inlineconstexpr |
Locale domain internal identifier for MeshLib's own translations.
|
inlineconstexpr |
Locale domain internal identifier for cross-domain translations.