Talk Table files, or TLK files, commonly referred to dialog.tlk (the default games tlk file) is a GFF file which contained the strings used by the game, appropriately localised for different languages. You refer to entries in a TLK file by a "String reference" or StringRef.
The Bioware documentation has information on how the binary file is laid out. It is essentially has a number linked to a set of text, used for a few script functions (unlikely needed for a custom module unless it is localised) but primarily for in-game GUI text references as in many 2da Files. There is, if you have a larger persistent world, a possible saving of bandwidth by sending string reference script commands or using them in larger conversations (since only 4 bytes is sent, and looked up locally, compared to sending all the string piece by piece).
References are pretty simple for the default TLK file - for instance in the default dialog.tlk file has number 12 be the word Paladin, the singular class name as referenced in classes.2da. Under the "Name" column you'll see the number 12 for the Paladin line - a string reference number to the entry.
Conversations also can use TLK file references, and the entries are formatted the same way (tokens for colours, for instance).
For a module specific TLK file see below for how to reference it with the magic number.
Hardcoded Line References
There are a large number of engine hardcoded line references - with the script command SetTlkOverride they can be altered before being displayed.
These are slowly being documented on the page Hardcoded TLK Lines so are easier to replace.
In NWN:EE some of the hardcoded references to files that are usually easily moddable, eg; spellschool.2da - are getting fixed - making it a lot more sensible for those aspects.
A TLK file has a specific language, including Male/Female variants for certain languages (which default to Male) - by having a dialogf.tlk (or xxxxxf.tlk for a custom one).
Things that work using them:
- 2da StringRefs
- Conversations that use TLK entries
- Item descriptions/names (if carefully edited in) that use TLK entries
Things that do not work fully:
- GetStringByStrRef - works fine in singleplayer, but in multiplayer this uses the servers language since the scripts are run server-side. You can't get the clients language or specify one for this function.
Some lines will have custom tokens, these will be referenced on the 2da pages if applicable and are swapped out for context-sensitive information. For a custom monster ability added to spells.2da you might want to have the ability name appear properly as "Monster uses Raging Fury." - for which the TLK line would be "<CUSTOM0> uses Raging Fury.".
Since TLK entries can be referenced in conversations (the games dialog.tlk has the entire game script in it which is why it is so large) they can also contain the standard conversation tokens, such as <StartCheck></Start>, <man/woman> etc. as well as color tokens. See Conversations for more information on these.
New Lines and Tabs
You can use the escaped characters for functionality (although these characters can be put in the TLK file it might be very useful for SetTlkOverride).
- \n for newline
- \t for a tab
Custom TLK Files
You can add 1 custom TLK file to a module. This requires you to merge TLK files if you are merging together content. You can distribute different language files of the same name, or "xxxf.tlk" for the female variant.
Adding a Custom TLK file to a module
To do so edit the Custom Content tab of the module properties, the Custom Tlk File drop-down allows you to select one of the ones present in C:\Users\xxxx\Documents\Neverwinter Nights\tlk
As usual they need to be 16 characters + .tlk extension. They can go in a hakpack (whether or not the toolset likes this - you can always put it in a hakpack AND in the tlk folder, but only distribute the hakpack).
Using a Custom TLK File
To use the TLK numbers, well, they start at 1, so Bioware made a magic number to add onto any entry in the custom file - 16,777,216 (0x01000000 in hexidecimal). Your custom tlk file entry 0 will need 16,777,216 being referenced. 1 would be 16,777,217 and so forth.
This means you need to translate your numbers properly back and forth. Some TLK editors include this functionality - saving the TLK format properly but showing you the custom number version to use in the 2das, conversations or scripts you're working on.
Overriding the default dialog.tlk File
For servers this seems to be not possible yet (the dialog.tlk file is loaded at runtime - server hakpacks/nwsync run too late and it won't reload).
For singleplayer there are two options:
- Replacement of the original dialog.tlk file - "useful" if you are overriding base content that affects all SP modules. You'd simply have a user replace the dialog.tlk file in their main game install folder.
- USERDIR/ root on Android/iOS - these mobile platforms support having the dialog.tlk loaded from the root userdir, which if they're adding other files to /override or other locations it can then load it properly (and not override the base game data, which is usually write protected)
This also allows overriding of default hardcoded client strings in addition to base game changes that affect all modules.
There are a few TLK editors that you can use. For very small mods doing it all by hand on the TLK file itself can work. On larger projects compiling a tlk file from another source (which has a spellchecker or other editing tools) may be better.
This section needs completing - some common TLK editing tools include:
- neverwinter.nim has command line tools to decompile and compile TLK files to/from JSON. nasher also uses this.
- xoreos-tools has command line tools to decompile and compile TLK files to/from XML (xml2tlk and tlk2xml)
- https://neverwintervault.org/project/nwn1/other/tool/axe-murderers-killer-tlk-editor - Windows only, a solid read editor and has some helper functionality for conversation tokens.
- https://neverwintervault.org/project/nwn2/other/tool/2datlkgff-editor-aka-tlkedit2 - Required Java - includes a way to see the magic custom content number, but write the real number
- https://neverwintervault.org/project/nwn1/other/tool/meaglyns-nwn-tlk-compiler - Linux only to/from TSL text files
Editing a text file (JSON or XML) is preferable for anything other than a tiny project, since you can sort a spell checker and do differentials more easily when using github or similar to store and version control it.