Locale module

The text the player reads, in the player's own language.

Functions

  • trx.locale.declare(strings)
    Declares game string keys and the text behind them.

    A key belongs with the script that shows it, so a command carries its own wording. What is declared here is a fallback, and it takes only for a key nothing else holds: the strings files, their translations, and any earlier declaration keep the text they already carry.

    Parameters:

    • strings (table). Keys to their English text.

    Example:

    trx.locale.declare({
      ["console/cmd/heal/help"] = "Heals Lara back to full health.",
      ["console/cmd/heal/success"] = "Healed Lara back to full health",
    })
    
  • trx.locale.get(key)
    The text behind a game string key.

    Parameters:

    • key (string). The key, e.g. general/misc/off.

    Returns: string. The key itself if nothing is behind it, so a typo shows up on screen rather than as a nil further down.

    Example:

    trx.console.log(trx.locale.get("general/misc/off"))
    
  • trx.locale.format(key, ...)
    The text behind a key with its placeholders filled in.

    Parameters:

    • key (string). The key, e.g. general/misc/off.
    • ... (any). What to fill the placeholders with.

    Returns: string. The text with the arguments in it. A translation whose placeholders do not line up with the arguments comes back unformatted, with a warning in the log: a player is better served by text they can read than by a script that stops.

    Example:

    trx.console.log(trx.locale.format("general/misc/pagination_nav", 1, 5))
    
  • trx.locale.reload()
    Reloads the current language's text from disk.

    Returns: boolean. Whether the reload succeeded.