Summary#
An app's own words — every Text("…"), label, title and message in its source — are written in one language. That is
English unless the app says otherwise, once, beside its culture:
app.SourceLanguage = "es"; // the words in this app's source are Spanish
app.DefaultCulture = "es-ES"; // …and numbers, money and dates are formatted the Spanish waySignature#
app.SourceLanguage = "<language tag>"; // "es", "sv", "de", "pt-BR" — a string literal; default "en"A value that is not a language tag in a string is a compile error at its line, in osy validate and the compile alike.
Description#
What it changes.
| without it | app.SourceLanguage = "es" | |
|---|---|---|
<html lang> when no translation is served | en | es |
App.Languages | ["en", …translations] | ["es", …translations] |
| a browser that asks for English | is given the source text, labelled en | is given the source text, labelled es — unless the app ships English |
Session.Language with nothing chosen | en | es |
a [Translatable] value read in this language | the stored value | the stored value (it is the source) |
English is a translation like any other. An app written in Spanish speaks only Spanish until it ships its own
English words — translations en { … }, usually in locales/en.osy (A language's words — locales/<language>.osy). Then English is offered,
chosen by the browser, the reader's own [PreferredCulture] or a switch exactly as any other language is
(Which language a reader gets — and switching it).
A kit's words in the source language. The kits are written in English. A Spanish app that wants their buttons and
messages in Spanish translates them in its own locales/es.osy (osy translate writes the entries, marked with each
kit's name). Those are used whenever the reader's language is the source.
Not the culture. app.DefaultCulture decides how numbers, money and dates are written (Culture formatting — ToString(format, culture));
app.SourceLanguage decides which language the words are. A Spanish app usually sets both.
Examples#
app.SourceLanguage = "es";
[Route("/")]
[AllowAnonymous]
component Inicio() {
render {
Stack(gap: 2) {
Text("Tu cesta está vacía.");
Text(Session.Language); // "es" — the source, until the app ships another language
}
}
}app.SourceLanguage = "es";
[Route("/")]
[AllowAnonymous]
component Inicio() { render { Text("Tu cesta está vacía."); } }
translations en {
text "Tu cesta está vacía." => "Your bag is empty.";
}See also#
- Which language a reader gets — and switching it — which language a reader gets, and switching it
- A language's words — locales/<language>.osy — the languages an app speaks, and its locale files
- Culture formatting — ToString(format, culture) —
app.DefaultCulture, the culture numbers and dates are written in