endstone/lang
Classes
| Name | Description |
|---|---|
Language | Represents the interface for translating text into different languages. |
Translatable | Represents 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
| Name | Description |
|---|---|
~Language | |
translate | Translates a given text into the current locale. |
translate | Translates a given text into a specific locale. |
translate | Translates a given text using a set of parameters for the current locale. |
translate | Translates a given text using a set of parameters for a specific locale. |
translate | Translates a Translatable object into the current locale. |
translate | Translates a Translatable object into a specific locale. |
getLocale | Gets the current locale. |
meth~Languagevirtual
~Language() =defaultmethtranslateabstractconst
std::string translate(std::string text) const =0Translates a given text into the current locale.
Parameters
| Name | Type | Description |
|---|---|---|
text | std::string | The text to be translated. |
Returns
| Type | Description |
|---|---|
std::string | The translated text in the current locale. |
methtranslateabstractconst
std::string translate(std::string text, std::string locale) const =0Translates a given text into a specific locale.
Parameters
| Name | Type | Description |
|---|---|---|
text | std::string | The text to be translated. |
locale | std::string | The locale identifier for the desired translation (e.g., "en_US"). |
Returns
| Type | Description |
|---|---|
std::string | The translated text in the specified locale. |
methtranslateabstractconst
std::string translate(std::string text, std::vector<std::string> params) const =0Translates a given text using a set of parameters for the current locale.
Parameters
| Name | Type | Description |
|---|---|---|
text | std::string | The text to be translated. |
params | std::vector<std::string> | A list of parameters to be used in the translation. |
Returns
| Type | Description |
|---|---|
std::string | The 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 =0Translates a given text using a set of parameters for a specific locale.
Parameters
| Name | Type | Description |
|---|---|---|
text | std::string | The text to be translated. |
params | std::vector<std::string> | A list of parameters to be used in the translation. |
locale | std::string | The locale identifier for the desired translation (e.g., "en_US"). |
Returns
| Type | Description |
|---|---|
std::string | The translated text in the specified locale, with parameters applied. |
methtranslateabstractconst
std::string translate(Translatable translatable) const =0Translates a Translatable object into the current locale.
Parameters
| Name | Type | Description |
|---|---|---|
translatable | Translatable | A Translatable object containing text and parameters. |
Returns
| Type | Description |
|---|---|
std::string | The translated text in the current locale. |
methtranslateabstractconst
std::string translate(Translatable translatable, std::string locale) const =0Translates a Translatable object into a specific locale.
Parameters
| Name | Type | Description |
|---|---|---|
translatable | Translatable | A Translatable object containing text and parameters. |
locale | std::string | The locale identifier for the desired translation (e.g., "en_US"). |
Returns
| Type | Description |
|---|---|
std::string | The translated text in the specified locale. |
methgetLocaleabstractconst
std::string getLocale() const =0Gets the current locale.
Returns
| Type | Description |
|---|---|
std::string | A 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
| Name | Description |
|---|---|
Translatable | |
getText | Get the text to be translated. |
getParameters | Get the translation parameters. |
empty | Check if the message to be translated is empty. |
methTranslatableexplicit
Translatable(std::string text, std::vector<std::string> params = {})methgetTextconst
const std::string& getText() constGet the text to be translated.
Returns
| Type | Description |
|---|---|
const std::string& | the text to be translated |
methgetParametersconst
const std::vector<std::string>& getParameters() constGet the translation parameters.
Returns
| Type | Description |
|---|---|
const std::vector<std::string>& | the translation parameters |
methemptyconst
bool empty() constCheck if the message to be translated is empty.
Returns
| Type | Description |
|---|---|
bool | true if the message to be translated is empty, false otherwise |