This interface represents the options that can be passed to a GobstonesTranslator. This options are passed on construction time, and shape the way the translator works, which locales it supports and from which and to which locale it will be translating to.

Hierarchy

  • GobstonesTranslatorOptions

Properties

from?: string

The locale which the GobstonesTranslator will assume as source locale when given Gobstones Localized code. This is the source language used in toTokens and as the source language in translate.

locales?: Record<string, LocaleDefinition>

A set of additional user defined locales to register into the GobstonesTranslator. By specifying a name of the locale and a set of token to string translations, you are entitled to used your user defined locale as any other, both as source or as destination language in a translation or token conversion.

Even though we recommend using the standard format for naming a locale, any string can be used as a name for the newly registered locales.

Note that you must specify all token names and their corresponding translation or extend a previously defined locale in order for a new registered locale to be correct.

Example

   languages: {
'en-GB': {
extends: 'en',
GBS_TYPE_COLOR: 'Colour'
},
'fr': {
GBS_GRAB: 'Prenez',
GBS_COLOR_RED: 'Rouge'
// extend with all other token names here
}
}
names?: Record<string, string>

A set of additional names to translate besides the built-in commands, expressions and keywords of the Gobstones Language. This allows for the translation of user defined procedures, functions, type names, variables and parameters.

Note that there is no scoping on variable/parameter renaming, and the conversion is limited to a word by word match.

Example

   names: {
'Poner__Veces': 'Drop__Times',
'colorAPoner': 'colorToDrop'
}
to?: string

The locale which the GobstonesTranslator will assume as destination locale when given Gobstones Abstract code or a Gobstones Localized code to convert to a different locale. This is the destination language used in fromTokens and as the destination language in translate.

tokenPrefix?: string

This is a debugging option only, and should not be used by users of the library.

Set the prefix that is going to be used for each token in the output. By specifying a string that contains non Gobstones Language characters you ensure that there is no collision between user defined procedures and the token names. By default, '$' is used as a prefix.

See

the "Caveats" section in the README for more information.

tokenSuffix?: string

This is a debugging option only, and should not be used by users of the library.

Set the suffix that is going to be used for each token in the output. By specifying a string that contains non Gobstones Language characters you ensure that there is no collision between user defined procedures and the token names. By default, '$' is used as a suffix.

See

the "Caveats" section in the README for more information.