EditorLanguages beta
Class of @v12-engine/editor
export declare class EditorLanguagesThe game's words in each of its languages (campaign plan LO2): a table of every key there is to say (the client's, the engine's, the game's view's, the plain texts of its maps, its campaign and its cinematics) and every name of what it defines, with the source of each (what the game's first language says) and its words in each language (GameView.languages), stale where the source changed since it was translated. Each language a file of the game's, languages/<id>.json (a MessagesFile), read here and written as a step of the history (a change until the map is saved, Ctrl+S), laid at once over the view here and in a game played here; out to CSV and back in. What the Languages panel does, in code
A part of the editor, as it gives it (editor.languages)
The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the EditorLanguages class.
Members
error
error(id: string): string | undefined;What is wrong with a language's file, where it could not be read: none when it reads
exportCsv
exportCsv(languages?: readonly string[]): string;The table as CSV (wordsCsv): key,table,source and a column a language, every other than the first when languages names none
first
first(): string | undefined;The language the game is written in, its words the source of every other's: none for a game with no languages
ids
ids(): string[];The game's languages, by id, in its order (GameView.languages): the first is the one it is written in, the source
importCsv
importCsv(text: string): Promise<{
changed: number;
languages: string[];
unknown: string[];
columns: string[];
}>;Reads a table back from CSV (exportCsv's, translated): each language column's words in the place of what that language says, one step of the history over every file changed. A row's source is what its words were made from (so words translated from a source changed since are stale); the source as it is now where the file has none. An empty cell changes nothing. What changed, how many, the keys the game has not (kept all the same) and the columns that are no language of the game's
keep
keep(id: string, key: string, table?: WordTable): Promise<void>;Marks a key's words in a language as made from its source as it is now: no longer stale. A step of the history
keys
keys(): string[];Every key of the table, as rows has them: a name's too (unit.footman)
load
load(id?: string, text?: string): Promise<void>;Reads each language's file from the game's files (languages/<id>.json; again, after one changed on disk: text for id), else what the view gives for it (fetched where it is a function), and the campaign's file. Each read is laid over the view at once. A file that does not read is left as it was, and what is wrong kept (error)
path
path(id: string): string;Where a language's file is among the game's files: languages/he.json
readMaps
readMaps(): Promise<number>;Reads the plain texts of every other map of the game in the project (their objectives and their rules' lines), so the table has their keys too: the map open is always read as it is. How many maps were read
row
row(key: string, table?: WordTable): WordRow | undefined;A row of the table, by its key (and its table, where a key is of both)
rows
rows(): WordRow[];Every key and name of the game, a row each, with its source and its words in each language, and where they are stale
set
set(id: string, key: string, words: string | undefined, table?: WordTable, merge?: string): Promise<void>;Sets what a key (or a name, table: 'names') says in a language, as a step of the history: written into its file with the hash of the source it is a translation of, so it is stale once that changes. Empty words or undefined take it out. Changes with the same merge key one after another are one step. Settles once it is written
stale
stale(id: string): string[];The keys whose words in a language were made from another source than they have now
table
table(id: string): MessagesFile;A language's table as the editor has it: as read or last written, else as the view gives it; empty before load
word
word(id: string, key: string, table?: WordTable): string | undefined;What a key (or a name) says in a language, as its table has it: none where it has no words for it