Skip to content

Words beta ​

Class of @v12-engine/client

ts
export declare class Words

What a client says things in (client.words, and the app's menus): the game's languages, the one in use, and the words of a key, a message or a name in it. A signal: what reads it follows a change of language

Members ​

constructor ​

ts
constructor(options?: {
        languages?: Languages;
        messages?: () => Record<string, MessageWords> | undefined;
        registry?: () => Registry | undefined;
    });

Constructs a new instance of the Words class

description ​

ts
description(kind: NameKind, id: string, fallback?: string): string | undefined;

What a definition says it is, in the language: a table's <kind>.<id>.description, else fallback (its definition's description, as the game writes it)

dir ​

ts
readonly dir: Accessor<'ltr' | 'rtl'>;

Which way the language in use is written. A signal

font ​

ts
readonly font: Accessor<string | undefined>;

The typefaces the language in use asks for, before the theme's (MessagesFile.font). A signal

hudWords ​

ts
hudWords(words: HudWords): HudWords;

The HUD's words in the language: what its tables say of them (hud.idle, hud.orders.move) over words

language ​

ts
readonly language: Accessor<string>;

The language in use, by id: the game's first until another is chosen (use). A signal

languages ​

ts
readonly languages: readonly string[];

The game's languages, by id, in its order: none in a game with one

lay ​

ts
lay(id: string, table: MessagesFile): void;

Puts a table in the place of a language's (the editor, as it writes one): said at once where it is in use, or is the game's first. Nothing for a language the game has not

message ​

ts
message(message: Message, viewer?: MessageViewer): string;

What a message says in the language: a table's words for its key (said to a player of a race, race.<race>.<key> first), else the view's, the engine's or the client's, else the key itself

name ​

ts
name(kind: NameKind, id: string, fallback?: string): string;

What a definition is called in the language: a table's <kind>.<id>, else fallback, else its definition's name

onChange ​

ts
onChange(listener: (id: string) => void): () => void;

Told each time the language changes: gives back what stops it

text ​

ts
text(key: string, params?: MessageParams): string;

What a key of the client's or the game's says in the language, with its params: words.text('ui.leave')

textOr ​

ts
textOr(key: string, fallback: string, params?: MessageParams): string;

What a key says in the language, as text, or fallback where nothing has words for it: what has words of its own as it is defined (a setting's label, over setting.<id>)

use ​

ts
use(id: string): Promise<void>;

Puts a language to use, by id, once its table is here: one the game has not is its first. What reads the words follows. Rejects where the table could not be fetched, the language in use staying