HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Friends
tt::l10n Class Reference

#include <ttauri/l10n.hpp>

Public Member Functions

constexpr l10n () noexcept
 Construct an empty message.
 
 l10n (l10n &&) noexcept=default
 
l10noperator= (l10n &&) noexcept=default
 
 l10n (l10n const &other) noexcept
 
l10noperator= (l10n const &other) noexcept
 
 operator bool () const noexcept
 Check if the message is in use.
 
template<typename... Args>
 l10n (std::string_view msg_id, Args const &...args) noexcept
 Construct a localizable message.
 
std::string operator() (std::vector< language * > const &languages=language::preferred_languages()) const noexcept
 Translate and format the message.
 
std::string operator() (std::locale const &loc, std::vector< language * > const &languages=language::preferred_languages()) const noexcept
 Translate and format the message.
 

Friends

bool operator== (l10n const &lhs, l10n const &rhs) noexcept
 Compare two localizable messages.
 

Detailed Description

A localizable message.

The translation and formatting of the message is delayed until displaying it to the user. This allows the user to change the language while the application is running.

Constructor & Destructor Documentation

◆ l10n() [1/2]

constexpr tt::l10n::l10n ( )
inlineconstexprnoexcept

Construct an empty message.

◆ l10n() [2/2]

template<typename... Args>
tt::l10n::l10n ( std::string_view msg_id,
Args const &... args )
inlinenoexcept

Construct a localizable message.

It is recommended to use the parentheses form of the constructor so that it will look like a function which is recognized by the gettext tool.

Parameters
msg_idA English string that is looked up in the translation database or, when not found, as-is. The msg_id may contain placeholders using the std::format format. Plurality is based on the first std::integral arguments.
argsArguments passed to std::format. The arguments are copied into the l10n object and used when formatting the translated string.

Member Function Documentation

◆ operator bool()

tt::l10n::operator bool ( ) const
inlineexplicitnoexcept

Check if the message is in use.

◆ operator()() [1/2]

std::string tt::l10n::operator() ( std::locale const & loc,
std::vector< language * > const & languages = language::preferred_languages() ) const
inlinenoexcept

Translate and format the message.

Find the translation of the message, then format it.

Parameters
localeThe locale to use when formatting the message.
languagesA list of languages to search for translations.
Returns
The translated and formatted message.

◆ operator()() [2/2]

std::string tt::l10n::operator() ( std::vector< language * > const & languages = language::preferred_languages()) const
inlinenoexcept

Translate and format the message.

Find the translation of the message, then format it.

Parameters
languagesA list of languages to search for translations.
Returns
The translated and formatted message.

Friends And Related Symbol Documentation

◆ operator==

bool operator== ( l10n const & lhs,
l10n const & rhs )
friend

Compare two localizable messages.

Parameters
lhsA localizable message.
rhsA localizable message.
Returns
True if both messages are equal.

The documentation for this class was generated from the following file: