# rmp::lang

> rmp::Text and rmp::lang -- the game in more than one language.

Source: https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-lang.html

namespace `#include <rmp/text.h>`

[`rmp::Text`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Text.html) and `rmp::lang` — the game in more than one language.

```cpp
rmp::ui::button("Play");                              // translated
rmp::ui::text(rmp::Text("{count} gem|{count} gems", { { "count", gems } }));
rmp::ui::button(rmp::Text("Open", { .context = "door" }));
rmp::lang::set("es");
```

Every text the framework is handed is an [`rmp::Text`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Text.html). A literal written in the call becomes one by itself, and it is TRANSLATED: its own words are the key looked up in the game's tables (resources/lang.tsv, resources/lang/<code>.tsv, `[lang] in` raylib_multiplatform.toml), and what is not there is shown as written. A string made at runtime — a std::string, `TextFormat()`'s answer — is shown as it is and never looked up: it has no stable key. A value that changes goes into a placeholder instead, so the key stays the same: [`rmp::Text`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Text.html)("Score: {score}", { { "score", score } }).

Placeholders are {name}; {{ and }} are a brace. A text with a number in it can have plural forms, separated by |, in the order of the language's CLDR categories: English and Spanish one|other, Russian and Polish one|few|many|other, Japanese and Chinese other alone. The first number among the arguments chooses. The language is the player's system language, the one [`rmp::lang::set()`](https://omardev29.github.io/rmp-docs/reference/namespaces/rmp-lang.html#set) chose (and saved), or `[lang] default`; es-MX falls back to es, then to the default, then to the text as written.

Right-to-left and complex shaping (Arabic, Hebrew, the Indic scripts) are not supported: their text is drawn left to right, letter by letter.

### `set`

void set(std::string_view code)

function [include/rmp/text.h:140](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/text.h#L140)

Change the language, everywhere at once: the next frame draws in it. "es", "es-MX", "ja". Saved, so the next run starts in it. An unknown code shows the default language's texts.

### `current`

std::string current()

function [include/rmp/text.h:143](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/text.h#L143)

The language in use.

### `available`

std::vector<std::string> available()

function [include/rmp/text.h:147](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/text.h#L147)

The languages a language menu offers: `[lang] languages`, in its order, or, with no list, every column and file the tables have.

### `name`

std::string name(std::string_view code)

function [include/rmp/text.h:151](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/text.h#L151)

A language's own name, for that menu: the table's row "language.name" in that language's column, or the code when the table has none.

### `translate`

std::string translate(std::string_view key, std::string_view context = {})

function [include/rmp/text.h:154](https://github.com/omardev29/raylib_multiplatform/blob/982bf2a1e307c49776bff84211260703b8de6895/include/rmp/text.h#L154)

The text `key` in the current language, as [`rmp::Text`](https://omardev29.github.io/rmp-docs/reference/classes/rmp-Text.html) would draw it.
