Manual

Manual · API

system

The machine and the person at it — language, appearance, clipboard.

Every command on this page carries a worked example.

language property

system.language

The language macOS is set to — "de".

Worked example
// Translate into the reader's own language, not a hard-coded one:
form.record.noteTranslated = language.translate(form.record.note,
                                                { to: system.language });

languages property

system.languages

The preferred languages, best first.

Worked example
log(system.languages);   // ["de-DE", "en-US", …] — best first

region property

system.region

"DE".

Worked example
const vatRate = system.region === "DE" ? 19 : askForRate();

locale property

system.locale

"de_DE".

Worked example
log(system.locale);   // "de_DE"

timeZone property

system.timeZone

"Europe/Berlin".

Worked example
log(system.timeZone);   // "Europe/Berlin"

appearance property

system.appearance

"light" or "dark", right now.

Worked example
const ink = system.appearance === "dark" ? "#eee" : "#222";

userName property

system.userName

The person logged in at this Mac.

Worked example
form.record.enteredBy = system.userName;

computerName property

system.computerName

This Mac's name.

Worked example
log("Running on", system.computerName);

isSandboxed property

system.isSandboxed

Whether the application runs sandboxed.

Worked example
if (system.isSandboxed) {
    // An App Store build cannot write everywhere — say so instead of failing.
}

information function

system.information()

All of the above in one object — what a log line wants.

One good habit: log(system.information()) in app.onStart — every support log then begins with the machine it happened on.
Worked example
// The first line of every support log:
log(system.information());

languageName function

system.languageName(code)

languageName("de")"German" — codes are for machines.

Worked example
form.languageLabel.value = "Written in "
    + system.languageName(language.detect(form.record.note));

copy function

system.copy(text)

Puts text onto the clipboard.

Worked example
system.copy(form.record.email);
messages.beep();   // the quiet "got it"

paste function

system.paste()

What is on the clipboard.

Worked example
const pasted = system.paste();
if (pasted !== null && pasted.includes("@")) {
    form.record.email = pasted.trim();
}

beep function

system.beep()

The system sound — the same one messages.beep() plays; it lives in both groups because both subjects own it.

Worked example
system.beep();

openURL function

system.openURL("mailto:…")

Web, mail, telephone — whatever macOS opens for that scheme.

Build mail links with encodeURIComponent for subject and body — spaces and umlauts break naked URLs.
Worked example
// The contact window's mail button:
const contact = form.record;
contact.save();
system.openURL("mailto:" + contact.email
    + "?subject=" + encodeURIComponent("Your order"));