On this page

Insality/defold-lang/lang.lang

Localization helpers for Defold: string tables, pluralization, and locale fallback.

  • GitHub: Insality/defold-lang — pinned to 2fe3aed
    1. Pick a release from Insality/defold-lang releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as lang from "lang.lang"

Functions

init()

set_lang(lang_id?: string)

Parameters

  • lang_id?: string

get_lang(): string

Returns

  • string

get_langs(): string[]

Returns

  • string[]

set_next_lang()

get_next_lang(): string

Returns

  • string

is_exist(text_id: string): boolean

Parameters

  • text_id: string

Returns

  • boolean

txt(text_id: string): string

Parameters

  • text_id: string

Returns

  • string

txp(text_id: string, params: any[]): string

Parameters

  • text_id: string
  • params: any[]

Returns

  • string

txr(text_id: string): string

Parameters

  • text_id: string

Returns

  • string

set_logger(logger_instance: LoggerInstance)

Parameters

  • logger_instance: LoggerInstance

set_logger(remove_logger_instance: undefined)

Parameters

  • remove_logger_instance: undefined

reset_state()

Types

LoggerInstance.trace(this: any, message: string, data?: {})

Parameters

  • this: any
  • message: string
  • data?: {}

LoggerInstance.debug(this: any, message: string, data?: {})

Parameters

  • this: any
  • message: string
  • data?: {}

LoggerInstance.info(this: any, message: string, data?: {})

Parameters

  • this: any
  • message: string
  • data?: {}

LoggerInstance.warn(this: any, message: string, data?: {})

Parameters

  • this: any
  • message: string
  • data?: {}

LoggerInstance.error(this: any, message: string, data?: {})

Parameters

  • this: any
  • message: string
  • data?: {}