ZuloOne
English
Sign in
Menu

Add a script resource

Updated

Text the user sees is a resource, not a C# literal. A refusal, a log line a person reads, a generated document title — a named row with a value per language, owned by the script that shows it. The rule and the resolution order are Text a script shows. What reaches the toast is What the user reads when an operation fails.

Note

The key belongs to this script. Create it on that script's Resources tab, not on Developer → Resources. A shared (unscoped) key is a fallback for text that is truly nobody's, not a shortcut to typed Res.Key.

How to#

1. Create the key on the running script's Resources tab. Fill Value (English), RU, and AR in the same change. A key with only Value is a decision not to translate, not a translation that comes later.

2. Call it from the script. Typed Res.NameRequired, or GetResource("NameRequired"). GetResource takes an explicit culture when the reader is not the current user — a document sent to a customer.

if (string.IsNullOrEmpty(record.Name))
    return Task.FromResult(EventResult.Cancel(Res.NameRequired));

A new key needs a compile: Res is generated. Changing the text of an existing key is live — running scripts see it at once.

Identifiers stay strings in code, where a typo is a compile error: subtype values, register analytic names, cache keys. Those are not resources.

Object and field names are captions, not script resources. ⓘ copy is in-app help.

Warning

A service is not the running script. GetService<IFoo>() runs inside the caller — the event handler, command, or test — so a key bound to the service's own script is not found and Res.Key returns the key name. Text a service returns to whoever calls it is shared: leave that resource unscoped, or put the key on the event or command that shows the sentence.

Resolution is owner-first: the running script's row, then the unscoped row, then the key name itself.

What's not there yet#

There is no per-script namespace in Res, so IntelliSense lists keys that belong to other scripts (resolution is still per running script). Nothing warns on a key with empty RU / AR. No gate fails a C# literal that should have been a resource — this page is the rule.

Where next#

Was this page helpful?