endstone/lang

Classes

NameDescription
LanguageRepresents the interface for translating text into different languages.
TranslatableRepresents an object with a text representation that can be translated by the Minecraft client.

classLanguage

Defined in <endstone/lang/language.h>

Represents the interface for translating text into different languages.

Methods

NameDescription
~Language
translateTranslates a given text into the current locale.
translateTranslates a given text into a specific locale.
translateTranslates a given text using a set of parameters for the current locale.
translateTranslates a given text using a set of parameters for a specific locale.
translateTranslates a Translatable object into the current locale.
translateTranslates a Translatable object into a specific locale.
getLocaleGets the current locale.

meth~Languagevirtual

~Language() =default

methtranslateabstractconst

std::string translate(std::string text) const =0

Translates a given text into the current locale.

Parameters

NameTypeDescription
textstd::stringThe text to be translated.

Returns

TypeDescription
std::stringThe translated text in the current locale.

methtranslateabstractconst

std::string translate(std::string text, std::string locale) const =0

Translates a given text into a specific locale.

Parameters

NameTypeDescription
textstd::stringThe text to be translated.
localestd::stringThe locale identifier for the desired translation (e.g., "en_US").

Returns

TypeDescription
std::stringThe translated text in the specified locale.

methtranslateabstractconst

std::string translate(std::string text, std::vector<std::string> params) const =0

Translates a given text using a set of parameters for the current locale.

Parameters

NameTypeDescription
textstd::stringThe text to be translated.
paramsstd::vector<std::string>A list of parameters to be used in the translation.

Returns

TypeDescription
std::stringThe translated text in the current locale, with parameters applied.

methtranslateabstractconst

std::string translate(std::string text, std::vector<std::string> params, std::string locale) const =0

Translates a given text using a set of parameters for a specific locale.

Parameters

NameTypeDescription
textstd::stringThe text to be translated.
paramsstd::vector<std::string>A list of parameters to be used in the translation.
localestd::stringThe locale identifier for the desired translation (e.g., "en_US").

Returns

TypeDescription
std::stringThe translated text in the specified locale, with parameters applied.

methtranslateabstractconst

std::string translate(Translatable translatable) const =0

Translates a Translatable object into the current locale.

Parameters

NameTypeDescription
translatableTranslatableA Translatable object containing text and parameters.

Returns

TypeDescription
std::stringThe translated text in the current locale.

methtranslateabstractconst

std::string translate(Translatable translatable, std::string locale) const =0

Translates a Translatable object into a specific locale.

Parameters

NameTypeDescription
translatableTranslatableA Translatable object containing text and parameters.
localestd::stringThe locale identifier for the desired translation (e.g., "en_US").

Returns

TypeDescription
std::stringThe translated text in the specified locale.

methgetLocaleabstractconst

std::string getLocale() const =0

Gets the current locale.

Returns

TypeDescription
std::stringA string representing the current locale (e.g., "en_US").

classTranslatable

Defined in <endstone/lang/translatable.h>

Represents an object with a text representation that can be translated by the Minecraft client.

Methods

NameDescription
Translatable
getTextGet the text to be translated.
getParametersGet the translation parameters.
emptyCheck if the message to be translated is empty.

methTranslatableexplicit

Translatable(std::string text, std::vector<std::string> params = {})

methgetTextconst

const std::string& getText() const

Get the text to be translated.

Returns

TypeDescription
const std::string&the text to be translated

methgetParametersconst

const std::vector<std::string>& getParameters() const

Get the translation parameters.

Returns

TypeDescription
const std::vector<std::string>&the translation parameters

methemptyconst

bool empty() const

Check if the message to be translated is empty.

Returns

TypeDescription
booltrue if the message to be translated is empty, false otherwise

On this page