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

#include <hikogui/i18n/translate.hpp>

Public Member Functions

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

Friends

constexpr friend bool operator== (translate const &lhs, translate 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

◆ translate() [1/3]

constexpr v1::translate::translate ( )
inlineconstexprnoexcept

Construct an empty message.

◆ translate() [2/3]

constexpr v1::translate::translate ( std::string_view msg_id)
inlineconstexprnoexcept

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.

◆ translate() [3/3]

template<typename FirstArg , typename... Args>
v1::translate::translate ( std::string_view msg_id,
FirstArg const & first_arg,
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.
first_argThe first argument passed to std::format().
argsArguments passed to std::format().

Member Function Documentation

◆ operator bool()

constexpr v1::translate::operator bool ( ) const
inlineexplicitconstexprnoexcept

Check if the message is in use.

◆ operator()() [1/2]

std::string v1::translate::operator() ( std::locale const & loc,
std::vector< language * > const & languages = os_settings::languages() ) const
inlinenoexcept

Translate and format the message.

Find the translation of the message, then format it.

Parameters
locThe 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 v1::translate::operator() ( std::vector< language * > const & languages = os_settings::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==

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: