Localizing Strings in Daggerfall Unity – Part 1
Localizing Strings in Daggerfall Unity – Part 2
Localizing Strings in Daggerfall Unity – Part 3
Localizing Strings in Daggerfall Unity – Part 4
Localizing Strings in Daggerfall Unity – Part 5
Localizing Strings in Daggerfall Unity – Part 6
Understanding RSC Markup
Before configuring our mod for distribution, we’re going to look back at the Demo_RSC string table from Part 2. Here, you saw tags like [/center] and [/left] combined with plain text. This is called RSC markup. See screenshot below with some markup highlighted. To fully translate Daggerfall’s text will require an understanding of how to use this markup in RSC strings.
Strings imported from TEXT.RSC contain bytecode controlling how each line of text is to be formatted. Like TEXT.RSC itself, this bytecode is in a binary format and is not easily read or edited by humans. If this bytecode stream was to be translated directly into numbers with no other changes, it would look something like below.
STRENGTH[0xFD] Strength governs encumbrance, weapon damage[0xFC] and the ease of increasing strength-related skills.[0xFC] With your strength of %str, you are considered %ark[0xFC] [0xFB][0x14]%dam [0xFB](modifier is factored into your[0xFC] [0xFB](hand-to-hand / weapon damage.[0xFC] [0xFB][0x14]%enc [0xFB](kilograms is your maximum encumbrance.[0xFC][0xFE]
This is obviously not pleasant for humans to work with. To overcome this, Daggerfall Unity’s localization system converts raw RSC bytecode into neatly formatted RSC markup with plain-text codes standing in for raw numbers. Line breaks are added where appropriate to help make text more readable and simulate how it will format in-game. The end result seen in RSC string tables now looks like below.
STRENGTH[/center] Strength governs encumbrance, weapon damage[/left] and the ease of increasing strength-related skills.[/left] With your strength of %str, you are considered %ark[/left] [/pos:x=20,y=0]%dam [/pos:x=40,y=0]modifier is factored into your[/left] [/pos:x=40,y=0]hand-to-hand / weapon damage.[/left] [/pos:x=20,y=0]%enc [/pos:x=40,y=0]kilograms is your maximum encumbrance.[/left] [/end]
At runtime, RSC markup text is converted back into a bytecode stream and printed to screen by Daggerfall’s UI based on these codes. It’s important not to translate markup codes. Anything contained inside of square brackets [ ] in an RSC-compatible string table will be treated as markup code.
Following is a summary of supported codes so far.
- [/center] – Centre align this line and starts new line.
- [/left] – Left align this line and starts a new line.
- [/newline] – Starts a new line.
- [/record] – Ends a sub-record for multi-record text (e.g. variants of answers or rumours in conversations).
- [/input] – Requests a prompt from player (e.g. entering “yes” to open gates in Castel Daggerfall).
- [/pos:x=0,y=0] – Position prefix for text aligned within UI (e.g. indented text under some other text). The X and Y values determine how far text is offset or indented from start position.
- [/end] – End orecord. Each RSC record must contain [/end] once all data is completed. This tells the reader there are no more subrecords or data to read for this key.
As you work through the RSC strings, remember to never change anything between square brackets [ ] or the formatting will be broken. And as a general rule, any markup code at the end of a line will also start a new line, except for [/end] which terminates the record.
You might have noticed many strings contain a word prefixed with % character, e.g. %str in text above. In Daggerfall Unity, these are called macros, as they expand into some other text when printed out. For example, %str will be converted into the character’s actual STR value at time text is printed – e.g. 65 will be printed in-game in place of %str.
There are over a hundred different macros in Daggerfall, so they won’t be covered in detail here. Just keep in mind that like markup codes above between [ ], you should never translate a macro prefixed with %. This macro code has special meaning to the game and changing it will break the purpose of the text and result in an unhandled error.
Variants in Legacy Import
There are a few places where Daggerfall Unity doesn’t have the exact same string records as classic. The main example of this is TEXT.RSC record 9000 – questions and answers for class questionnaire.
In classic, this is one large record with dozens of entries terminated by a special separator character. This record is so large that it’s very difficult for humans to edit even with RSC markup, and the length of text breaks the Unity string editor UI.
To overcome this, Daggerfall Unity splits record 9000 into multiple new records not present in classic TEXT.RSC – 9000.1 through 9000.40. Each record represents a single question/answer block for class questionnaire and does away with special separator character.
If you import legacy TEXT.RSC translations as we did with French and German, you will note that IDs 9000.1 through 9000.40 are not populated.
It will be necessary to manually translate these 40 records again, following the formatting example shown in English. The other locales did not use a legacy TEXT.RSC file so imported with the default English language version of text.
Translate Some RSC
Earlier in this series, we mentioned it’s also possible to translate English strings. There are a few reasons you might want to create an English translation, such as to fix spelling and formatting, or to change the “flavour” of text to create a unique game experience in your mod.
For a bit of fun, we’ll translate the English record for STRENGTH info popup into pirate speak.
Please be sure to have completed Parts 1-3 and confirmed your translated string tables appear in game.
It helps if you have a save game to load here, as we’re going to view something on the Character Sheet which requires an actual character. If you don’t have a character available, quickly start a new game to put together a basic character, then save that game.
To translate your STRENGTH info popup.
- Click Window menu > Asset Management > Localization Tables
- Dropdown Selected Table Collection and select Demo_RSC (StringTable)
- Locate key 0 for STRENGTH text. It will be at top of string table
- If you need to, enlarge editor window and drag around column widths until you can comfortably edit the English (en) value
- Copy and paste the entire block of text below into the English (en) value field
STRENGTH[/center] Ahoy matey! Strength governs yer encumbrance, weapon damage[/left] an' the ease o' increasin' strength-related skills.[/left] with yer strength o' %str, ye be considered %ark[/left] [/pos:x=20,y=0]%dam [/pos:x=40,y=0]modifier be factored into your[/left] [/pos:x=40,y=0]hand-to-hand / weapon damage.[/left] [/pos:x=20,y=0]%enc [/pos:x=40,y=0]kilograms be yer maximum encumbrance.[/left] [/end]
This should look like below.
You can now close the Localization Tables editor. To see your changes in-game:
- Click Play to start game
- Ensure English (en) is selected at the top-right of Game view
- Load a previously saved character
- Press F5 to open the Character Sheet UI (if you’ve changed this keybinding from default, use that key instead)
- Click on STR button to open the STRENGTH info popup
If everything has worked, it will look like below in-game.
Preparing to Distribute Mod
So far, we’ve done everything directly in the Unity Editor. This is fine for testing, but we eventually want to distribute translations so that others can use them. Getting ready for distribution will be the focus of next parts in this series.
Before we move on, we need to undo a couple of changes made in editor while testing. Moving forward, we’ll be preparing mod as if our translation work is completed and it’s time to ship the mod.
The first change to undo is the manual setting to use our string table collections.
- In DaggerfallUnityGame scene, click the TextManager object
- On the TextManager inspector, reset Live String Tables and other settings back to defaults as shown in below screenshot
- Save the scene using File menu > Save
We’re done with copying string tables, so empty those settings also.
Because we’re going to create a .dfmod for distribution, we need to ensure the DaggerfallUnityStartup scene is how we start the game. This scene is responsible for loading mods, and going direct to the game scene like we did for testing will skip this essential process.
Please open the DaggerfallUnityStartup scene now, and keep this scene open as you work through remainder of tutorial series.
Once you’ve opened DaggerfallUnityStartup scene, please check the settings for TextManager to ensure they’re still set to defaults as pictured above. We did not change startup scene’s TextManager, but please check it hasn’t been changed by mistake.
Now that we’ve reset TextManager properties and opened DaggerfallUnityStartup scene, we’re ready for Localizing Strings in Daggerfall Unity – Part 5.