14 lines
774 B
TypeScript
14 lines
774 B
TypeScript
// The user-visible text of the storage code and the domain code. These folders use no host module, so the skill helper
|
|
// can bundle them for Node. `message()` marks a key of the host catalog (`src/lib/i18n/messages.ts`), and the catalog
|
|
// audit counts it. The text stays English here. The interface translates it with `localize()` (`../ui/text.ts`).
|
|
|
|
/** Mark a catalog key. It returns the text unchanged. */
|
|
export function message<T extends string>(text: T): T {
|
|
return text;
|
|
}
|
|
|
|
/** Put the values into the `{name}` placeholders of a catalog key. */
|
|
export function format(template: string, values: Record<string, string | number>): string {
|
|
return template.replace(/\{(\w+)\}/g, (match, key: string) => Object.hasOwn(values, key) ? String(values[key]) : match);
|
|
}
|