Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Translation

Hierarchy

  • Translation

Index

Constructors

constructor

  • new Translation(dictionary: Dictionary | string, entry: number | string, index?: "random" | number): Translation
  • new Translation(translationId: string): Translation
  • Creates from a translation id. Entry matching is done by changing the case-style of the inputted translation id, so if you provide an all lower-case string it will not work!

    Examples that do work:

    • Ui:MenuMainButtonContinueGame
    • ui:menuMainButtonContinueGame
    • ui:menu-main-button-continue-game
    • Ui:Menu-Main-Button-Continue-Game
    • Player.FirstName:random
    • Creature.AcidSpitterDemon:1

    Examples that don't work:

    • UI:MENU-MAIN-BUTTON-CONTINUE-GAME
    • Ui:menumainbuttoncontinuegame
    • UI:MENUMAINBUTTONCONTINUEGAME

    Parameters

    • dictionary: Dictionary | string
    • entry: number | string
    • Optional index: "random" | number

    Returns Translation

  • Creates from a translation id. Entry matching is done by changing the case-style of the inputted translation id, so if you provide an all lower-case string it will not work!

    Examples that do work:

    • Ui:MenuMainButtonContinueGame
    • ui:menuMainButtonContinueGame
    • ui:menu-main-button-continue-game
    • Ui:Menu-Main-Button-Continue-Game
    • Player.FirstName:random
    • Creature.AcidSpitterDemon:1

    Examples that don't work:

    • UI:MENU-MAIN-BUTTON-CONTINUE-GAME
    • Ui:menumainbuttoncontinuegame
    • UI:MENUMAINBUTTONCONTINUEGAME

    Parameters

    • translationId: string

    Returns Translation

Properties

Readonly isValid

isValid: boolean

Static Readonly RANDOM

RANDOM: "random" = "random"

Static Readonly defaultInterpolator

defaultInterpolator: Interpolator = new Interpolator(TranslationSegment.thisEntry,bindSegment,tooltipSegment,reformatSegment,TranslationSegment.conditional,TranslationSegment.include,formatListSegment,italicizedSegment,boldSegment,underlineSegment,...basicInterpolator.segments,numberToPlacesSegment,numberToPercentSegment,numberDifferenceSegment,colorSegment,CapitalizationSegment.sentence,randomizationSegment,interpolateArgumentSegment,numberAsWordsSegment,numberAsRomanNumeralSegment,compatNumberSegment, // TODO remove on 1.0 release)

Static provider

Accessors

context

  • Returns TextContext

Methods

addArgs

  • addArgs(...args: any[]): this
  • Parameters

    • Rest ...args: any[]

    Returns this

get

  • Returns this translation as a list of string sections

    Parameters

    • Rest ...args: any[]

    Returns IStringSection[]

getString

  • getString(...args: any[]): string
  • Returns the translation as a string

    Parameters

    • Rest ...args: any[]

    Returns string

hasFailWith

  • hasFailWith(): boolean
  • Returns true if this translation has been set to fail with another translation or string.

    Returns boolean

hasTranslation

  • hasTranslation(): boolean
  • Returns boolean

inContext

  • inContext(context?: TextContext, normalize?: boolean): this
  • Parameters

    • Default value context: TextContext = TextContext.None
    • Default value normalize: boolean = false

    Returns this

orElse

passTo

serialize

setFailWith

  • Sets what this translation will return if there is no translation.

    Parameters

    Returns this

setRandom

  • setRandom(random?: Random): this
  • Sets the random source for this Translation. Uses general random by default, not seeded.

    Note: If this translation is an argument to another translation, it will use the random of the parent translation.

    Parameters

    • Default value random: Random = generalRandom

    Returns this

setReference

  • Parameters

    Returns this

toString

  • toString(): string
  • Returns string

withSegments

  • withSegments(...segments: ISegment[]): this
  • withSegments(priority: true, ...segments: ISegment[]): this
  • Parameters

    Returns this

  • Parameters

    • priority: true
    • Rest ...segments: ISegment[]

    Returns this

withTooltip

  • withTooltip(tooltip?: Falsy | ITooltipSection["tooltip"]): this
  • Parameters

    • Optional tooltip: Falsy | ITooltipSection["tooltip"]

    Returns this

Static colorizeImportance

  • Parameters

    • importance: "primary" | "secondary"

    Returns Translation

  • Parameters

    Returns IStringSection

  • Parameters

    Returns IStringSection[]

Static colorizeMessageType

Static colorizeQuality

  • Parameters

    • quality: Quality | string

    Returns Translation

  • Parameters

    Returns IStringSection

  • Parameters

    Returns IStringSection[]

Static colorizeStat

Static damage

  • Damage types are bit flags, so multiple can be stored in one DamageType. This method returns a translated list of damage types.

    Parameters

    Returns Translation

Static deserialize

Static empty

  • Returns Translation

Static formatList

Static generator

  • DO NOT USE THIS METHOD

    Unless the text is PRE-GENERATED and there is NO WAY TO TRANSLATE IT.

    Example uses include text the user inputs, and text from other sites (steam/trello)

    Parameters

    Returns TranslationGenerator

Static getAll

  • Parameters

    • dictionary: Dictionary | string
    • Optional entry: number | string

    Returns Translation[]

Static getString

Static isSerializedTranslation

  • isSerializedTranslation(thing: unknown): thing is ISerializedTranslation
  • Parameters

    • thing: unknown

    Returns thing is ISerializedTranslation

Static message

  • Parameters

    Returns Translation

Static milestone

  • Parameters

    • entry: string | Milestone
    • Default value color: boolean = false

    Returns Translation

Static misc

Static nameOf

  • Parameters

    • type: Dictionary

      The dictionary this entry is a part of. For instance, Dictionary.Item for ItemTypes.

    • thing: number | { renamed?: string | ISerializedTranslation; type: number }

      A entry (such as a ItemType) or an object containing the entry & a string for if the object has been renamed.

    • Optional article: undefined | false | true

      Whether to include the "article" in front of the name. Defaults to true. This follows article rules for the current language. In English, this is only for single items, "a/an"

    Returns Translation

  • Parameters

    • type: Dictionary
    • thing: number | { renamed?: string | ISerializedTranslation; type: number }
    • Optional count: undefined | number
    • Optional article: undefined | false | true
    • Optional showRenamedQuotes: undefined | false | true

    Returns Translation

Static ofNumber

  • Parameters

    • number: number
    • Default value failWith: string | Translation = `${number}`

    Returns Translation

Static quality

  • quality(entry: string | Quality, color?: boolean): Translation
  • Parameters

    • entry: string | Quality
    • Default value color: boolean = false

    Returns Translation

Static reformatSingularNoun

  • reformatSingularNoun(): Translation
  • reformatSingularNoun(count: number): Translation
  • reformatSingularNoun(article: boolean): Translation
  • reformatSingularNoun(count: number, article: boolean): Translation
  • reformatSingularNoun(count?: number | boolean, article?: undefined | false | true): Translation
  • Returns Translation

  • Parameters

    • count: number

    Returns Translation

  • Parameters

    • article: boolean

    Returns Translation

  • Parameters

    • count: number
    • article: boolean

    Returns Translation

  • Parameters

    • Optional count: number | boolean
    • Optional article: undefined | false | true

    Returns Translation

Static resolve

  • resolve(dictionary: Dictionary, entry: string | number, index?: undefined | number): string
  • Parameters

    • dictionary: Dictionary
    • entry: string | number
    • Optional index: undefined | number

    Returns string

Static romanNumeral

  • Parameters

    • number: number

    Returns Translation

Static skill

  • Parameters

    • entry: string | SkillType
    • Default value color: boolean = false

    Returns Translation

Static sorter

Static stat

  • Parameters

    • entry: string | Stat
    • Default value color: boolean = false

    Returns Translation

Static ui

Generated using TypeDoc