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- Pick a release from Insality/defold-lang releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as lang from "lang.lang"
- Pick a release from Insality/defold-lang releases and add its Source code (zip) URL (or a packaged
Functions
init()set_lang(lang_id?: string)get_lang(): stringget_langs(): string[]set_next_lang()get_next_lang(): stringis_exist(text_id: string): booleantxt(text_id: string): stringtxp(text_id: string, params: any[]): stringtxr(text_id: string): stringset_logger(logger_instance: LoggerInstance)set_logger(remove_logger_instance: undefined)reset_state()
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:stringparams: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:anymessage:stringdata?:{}
LoggerInstance.debug(this: any, message: string, data?: {})
Parameters
this:anymessage:stringdata?:{}
LoggerInstance.info(this: any, message: string, data?: {})
Parameters
this:anymessage:stringdata?:{}
LoggerInstance.warn(this: any, message: string, data?: {})
Parameters
this:anymessage:stringdata?:{}
LoggerInstance.error(this: any, message: string, data?: {})
Parameters
this:anymessage:stringdata?:{}