You write this:
Vue
<h1>Welcome back, {{ user.name }}</h1>
<p>Read the <a href="/guide">guide</a> before you <strong>deploy</strong>.</p>
<input placeholder="Search messages" />React
<h1>Welcome back, {user.name}</h1>
<p>
Read the <a href="/guide">guide</a> before you <strong>deploy</strong>.
</p>
<input placeholder="Search messages" />Svelte
<h1>Welcome back, {user.name}</h1>
<p>Read the <a href="/guide">guide</a> before you <strong>deploy</strong>.</p>
<input placeholder="Search messages" />The build writes this, the same for all three:
{
"112b1022f9": "Welcome back, {name}",
"2edbea9ab7": "Read the <0>guide</0> before you <1>deploy</1>.",
"ddf0602b21": "Search messages"
}Add locales/es.json with the same IDs, and the page speaks Spanish.
What you get
Section titled "What you get"- Plain text is the source. Text and the attributes people read are messages.
translate="no"opts an element out. - IDs from the text. An ID is a hash of the source text, so the same sentence anywhere is one message, and moving a link or a class keeps its ID.
- Translations survive edits. Rename a variable and every translation follows. Reword a sentence and the old translation stays next to it, to update.
- Built on x18n. Its CLI, editor extension, devtools and AI translation read and edit the catalogs through
glosa/x18n. - Live. Edit a catalog and the page updates without a reload.
setLocaleswitches language in place, and server rendering gets one store per request.