interfaces language - wxyz-abcd/node-haxball GitHub Wiki

Language

All properties and methods about global language handling reside in this object.

(Look inside examples/languages/englishLanguage.js for the default language function and example usage.)

1. Properties

  • current: string: This is the abbreviation of the current language. Defaults to 'GB'. It is possible to change the language of the whole API by changing this value directly; throws error if the language does not exist.

  • currentData: object: (read-only) Contains all name mappings for the current language, namely errorsTextMap, connectionStateTextMap and rendererTextMap that are already described in section 2.1.

  • indices: object: (read-only) Contains the global name-to-integer mappings that shortly describe the language string. This object has the following keys:

    • ErrorCodes: object: Name-to-integer mapping that shortly describes the error codes used in HBError class. Note that this is the same object as Errors.ErrorCodes.

    • ConnectionState: object: Name-to-integer mapping that shortly describes the connection states encountered while joining a room. Note that this is the same object as the API's global ConnectionState object.

    • RendererTextIndices: object: Name-to-integer mapping that shortly describes the default renderer's language text indices used inside the current default renderers.

2. Functions

  • add(abbr: string, errorsTextMap: object, connectionStateTextMap: object, rendererTextMap: object): void

    Adds a new language with given properties. Throws an error while trying to add an already-existing language.

    Parameters:

    • abbr: The language abbreviation value. Must be unique. This value is automatically transformed into upper-case.
    • errorsTextMap: An object that has a description function for each error code where each function returns a string.
    • connectionStateTextMap: An object that maps each connectionState number to a string value.
    • rendererTextMap: An object that maps each rendererTextIndex number to a string value.

    Return value: void.

  • remove(abbr: string): void

    Removes the language that has the given abbreviation value(abbr). Throws error while trying to remove a non-existent or current language.

    Parameters:

    • abbr: The language abbreviation value. This value is automatically transformed into upper-case.

    Return value: void.

⚠️ **GitHub.com Fallback** ⚠️