TLK file format

Applies to:
BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2


General Description
Most strings shown in Infinity Engine games are stored in a TLK file, usually dialog.tlk (for male/default text) and/or dialogf.tlk (for female text). Strings are stored with associated information (e.g. a reference to sound file), and are indexed by a (0-indexed) 32 bit identigier called a "Strref" (String Reference). Storing text in this way allows for a game to be easily swapped between languages.

Detailed Description
Overall structure

TLK V1 Header

Offset Size (data type) Description
0x0000 4 (char array) Signature ('TLK ')
0x0004 4 (char array) Version ('V1  ')
0x0008 2 (word) Language ID
0x000a 4 (dword) Number of strref entries in this file
0x000e 4 (dword) Offset to string data

TLK V1 Entries

This section is hardcoded to start at byte 18 from the beginning of the file. The string offsets are relative to the strings section.

Offset Size (data type) Description
0x0000 2 (word) Bit field:
  • 00 - No message data
  • 01 - Text exists
  • 02 - Sound exists
  • 03 - Standard message. Ambient message. Used for sound without text (BG1) or message displayed over characters head (BG2) , Message with tags (for instance <CHARNAME>) for all games except BG2
  • 04 - Token exists (for instance <CHARNAME>), BG2 and EEs only
0x0002 8 (resref) Resource name of associated sound
0x000a 4 (dword) Volume variance (Unused, at minimum in BG1)
0x000e 4 (dword) Pitch variance (Unused, at minimum in BG1)
0x0012 4 (dword) Offset of this string relative to the strings section
0x0016 4 (dword) Length of this string

TLK V1 Strings

This section is composed of ASCII strings. While some strings are NULL terminated, others are not, hence a combination of NULL terminators and the stirng length should be used to find the true string length. Indexing for these strings is done in the strref entries section.