Browse guides

Translate application content

Render the same message path from the active language dictionary.

The example registers English and Spanish messages, activates Spanish and displays `Hola`.

Table of contents

Main APIs

getLang
Returns the active translation language.
setLang
Selects which dictionary `t` resolves.
setTranslations
Configures the application's translation dictionaries.
t
Resolves a translated message by path and replaces the provided parameters.
v-t
Concept. Resolves translated children from a key.
ts
import { mount } from "valyrian.js";
import { setLang, setTranslations, t } from "valyrian.js/translate";

setTranslations({ greeting: "Hello" }, { es: { greeting: "Hola" } });
setLang("es");

mount("body", () => t("greeting"));

Exact references