bedrock-kit
    Preparing search index...

    Class LangFile

    Wraps a language .lang file from the resource pack's texts/ directory. Provides access to translations for items, blocks, entities, and other keys.

    const lang = addon.langFile; // defaults to en_US
    const swordName = lang.get("item.iron_sword.name"); // "Iron Sword"
    const missing = lang.get("item.doesnt_exist.name"); // "item.doesnt_exist.name" (fallback to key)

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    data: Record<string, unknown>

    The raw parsed JSON data of the asset file.

    docstrings: CommentBlock[]

    All JSDoc-style comment blocks parsed from this asset's source file, in document order. Empty array when no /** … */ blocks are present.

    filePath: string

    Absolute path to the asset's file on disk. Empty string in browser mode.

    language: string

    The language code, e.g. "en_US", "fr_CA".

    Accessors

    • get keys(): string[]

      Returns all translation keys in this file.

      Returns string[]

    • get size(): number

      Returns the number of translations.

      Returns number

    • get values(): string[]

      Returns all translated values in this file.

      Returns string[]

    Methods

    • Returns the translation for a key, or the key itself if not found. This matches Minecraft's behavior where missing translations show the raw key.

      Parameters

      • key: string

        The translation key, e.g. "item.iron_sword.name"

      Returns string

      The translated string, or the key if not found

    • Returns the translation for a key, or null if not found. Use this when you need to distinguish between missing translations and empty strings.

      Parameters

      • key: string

        The translation key

      Returns string

      The translated string, or null if not found

    • Returns all translations as an object. Useful for serialization or bulk operations.

      Returns Record<string, string>