Manual · API
language
The Mac reads for you — on the customer's own machine, nothing leaves it.
Timings are measured, never guessed — a 7,500-invoice database on an Apple-silicon Mac, warm, median of many runs (Spikes/CommandTimingSpike). green never needs a thought · amber is felt in a loop · red takes real time, show progress.
Every command on this page carries a worked example.
text function
language.text(text, placeholders)
A sentence meant for the person's eyes, in their language. The string in the code is the base language — no invented key — and without a translation, or in a single-language application, it comes back unchanged. Mark only what people read: a value in a where(…) is data and must never be translated. The IDE finds every marked sentence and lists it in the Translations editor by itself.
{number} travels with the translation, so a language with a different word order puts it where it belongs. A translation that loses a placeholder is reported as an error.Worked example
messages.alert(language.text("Saved!"));
const line = language.text("Invoice {number} saved",
{ number: invoice.number });
detect function
language.detect(text) ≈ 0.8 ms
The language of a text — "de", or null when the Mac cannot tell.
Worked example
const answer = xml.build({
order: { number: form.record.number, total: form.record.total }
});
files.writeText(target, answer);
sentiment function
language.sentiment(text) ≈ 1.5 ms
The mood, as −1…+1 — a complaint reads negative before anybody read it.
Worked example
const from = language.detect(form.record.note);
form.languageLabel.value = from === null
? "" : "Written in " + system.languageName(from);
canTranslate function
language.canTranslate(from, to)
Answers ready / needsDownload / unsupported first, so the first translation is not a surprise download.
Worked example
const mood = language.sentiment(form.record.note);
form.moodLabel.value = mood < -0.3 ? "Sounds unhappy"
: mood > 0.3 ? "Sounds pleased" : "";
translate function
language.translate(text, { to }) ≈ 0.35 s per sentence, warm
Apple's on-device translation — nothing leaves the Mac.
canTranslate first and offer the download knowingly — and system.language is usually the honest target: the reader's own.Worked example
// The contact window's button:
const from = language.detect(form.record.note);
if (from !== null && language.canTranslate(from, system.language) === "ready") {
form.record.noteTranslated =
language.translate(form.record.note, { to: system.language });
form.record.save();
}
Manual