Localizing Strings in Daggerfall Unity – Part 2

Series
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

Playing in Unity Editor

If you’ve followed tutorial up to this point, you should have the full Daggerfall Unity project open inside Unity 2019.4.10 and created some new locales and empty string tables.

As we progress, we’ll begin testing our translations directly inside of the Unity Editor. To make sure everything is working as expected, let’s begin by opening the startup scene.

  1. In Project view, navigate to Assets/Scenes
  2. Double-click DaggerfallUnityStartup scene to open it in the editor

The DaggerfallUnityStartup scene is the launcher window you see when running a game build. You should see the following structure in your Hierarchy view.

Now click the Play button to start Daggerfall Unity inside editor.

If you’ve previously setup Daggerfall Unity for regular play, it will open straight to the launcher UI in your Game view as normal.

If you’ve never setup Daggerfall Unity for play, you’ll first need to provide a good set of game files. We recommend the DaggerfallGameFiles zip available on Live Builds page.

For more information on setting up Daggerfall Unity for play, head over to Installing Daggerfall Unity and Other Information topic on our forums.

Try playing the game and loading a save if you have one. Everything should work inside the editor as if you were playing Daggerfall Unity normally from a build. When you’re ready, click Unity’s Play button once again to stop the game.

At this point, we’re ready to begin importing text and testing it in game. For convenience, we’re going to open the DaggerfallUnityGame scene to bypass the launcher and go straight into game.

  1. In Project view, navigate to Assets/Scenes
  2. Double-click DaggerfallUnityGame scene to open it in the editor

You’ll notice in Hierarchy there’s more inside the game scene. One particular object you should take note of is TextManager.

The TextManager object is our global interface to string tables and importing text. We’ll get back to this shortly, just remember where it is for now.

Understanding Legacy Translations

Before we bulk import text into our new string tables, some understanding is required about strings in classic Daggerfall.

If you’ve been around for a while and maybe helped translate classic Daggerfall, you will have encountered the problem of its limited 8-bit character set not being able to correctly code accented characters like ç or û.

The way translators had to work around this back then was to remap each accented character to one within Daggerfall’s available character set. For example, the following text:

compétences liées à la volonté

Would be written in modified TEXT.RSC data as:

comp<tences li<es @ la volont<

Then to make these characters appear correctly in game, font glyphs for < and @ were redrawn to look like é and à. Finally, when classic Daggerfall rendered this remapped text in game, it appears correct to the player. But underneath it all, the source text still uses < and @ in place of real character codes.

This means classic translators had to write various degrees of gibberish using remapped characters. And if the target language does not even resemble Latin characters (e.g. Cyrillic), then the work became even harder.

Daggerfall Unity has no such character limitation and can use text written normally with accented or non-Latin characters. It supports standard international character codes and fonts with any number of glyphs.

Unfortunately, legacy translations for classic Daggerfall were all created using remapped characters. When importing classic text data, e.g. from TEXT.RSC, these characters are imported as-is and the translated text just looks like gibberish as written.

Rather than discard legacy translations and start from scratch, Daggerfall Unity has the ability to undo character remappings back to their original character codes while performing a bulk import. This is handled by providing a TextMappingTable to string importer.

Understanding TextMappingTable

The TextMappingTable is a simple data file in .txt format providing conversion from a remapped character code back to their original character. Conversions for multiple locales can be stored in one TextMappingTable.

This tutorial provides a sample TextMappingTable for French (fr) and German (de) legacy strings. To create this table, copy the entire of below into a new text document.

-Character mapping database for importing classic text with remapped character data

schema: *key,locale,source,replacement

-French (fr)
0,   fr, $ , ç
1,   fr, < , é
2,   fr, # , è
3,   fr, @ , à
4,   fr, ^ , ê
5,   fr, ~ , ù
6,   fr, \ , â
7,   fr, ` , û
8,   fr, * , ë
9,   fr, { , ï
10,  fr, } , î
11,  fr, | , ô

-German (de)
12,  de, @ , Ä
13,  de, # , ä
14,  de, $ , Ö
15,  de, & , ö
16,  de, { , Ü
17,  de, } , ü
18,  de, * , ß

Save this text document as TextMappingTable.txt in your DemoTranslationMod/Resources folder created in previous tutorial.

If you’ve already saved document elsewhere, you can also drag and drop it into above path in Unity’s Project view.

If you need to add more locales to your TextMappingTable, follow the example above and be sure that each new line as a unique number for key. For example, the next available key in sequence above is 19.

Note: providing a TextMappingTable is not required if you plan to start from scratch with fresh translations, or don’t have legacy classic translations available.

Download Legacy Translations

We’re almost ready to bulk import classic text data into our string tables.

As a convenience, this tutorial provides legacy translated TEXT.RSC files for French (fr) and German (de). Please download the following zip and extract somewhere.

Download

The files in above download were created by the French and German communities respectively, and all credit belongs to those communities for their work:

When you unzip this archive, you will see it contains two TEXT.RSC files, each with a very specific filename.

The file “TEXT_fr.RSC.bytes” is the French TEXT.RSC file, and “TEXT_de.RSC.bytes” is the German TEXT.RSC. The file data is unchanged from source, only the names are changed so that Daggerfall Unity can identify which file belongs to which locale.

The “.bytes” extension is a Unity convention so resource loader knows the file is a binary asset.

Now that you have a couple of legacy translations available, you need to place them into your mod project.

  1. In Project view, navigate to DemoTranslationMod/Resources
  2. Drag and drop the translated and renamed TEXT.RSC files directly into your Resources folder

This will add the files to Resources along with the TextMappingTable.txt file we added earlier. Your DemoTranslationMod/Resources folder should now contain three files like below.

Note that Unity does not display the .bytes or .txt file extensions in editor.

Initialize String Table Collections

Everything is now in place to bulk import text from classic Daggerfall into your string table collections, which initializes all of them at once with the correct keys and starting text.

If you’ve provided the files above to DemoTranslationMod/Resources, the pre-translated text from TEXT.RSC in French (fr) and German (de) locales will be used, and their remapped character codes will be converted back to normal character codes thanks to the TextMappingTable.

All other locales will be initialised using the English (en) language as a starting point.

Note: As localization is still in Preview, not all text sources are supported for translations. At time of writing, Daggerfall Unity supports localization of strings from TEXT.RSC and strings exported from FALL.EXE. However, only TEXT.RSC is supported for bulk import at this time. Other than Quests and Books, this constitutes around 95%+ of all text in game. Support for more text sources, including Quests and Books, will be added in future.

Remember the TextManager in the Game scene from earlier? Click on this now to select it.

Then locate your Inspector view in editor and you will see that TextManager has a custom editor tool attached.

The Live String Tables are used by game at runtime. We’ll get to this in a later tutorial in series.

For now, we’re just going to copy our source text into the empty string table collections we created in first tutorial. For this we’ll use the Copy String Tables tool.

Enter settings as shown below and click Copy All. Don’t worry about BOK Strings for now. This field will be used later once Books are supported by localization.

After clicking Copy All, you should see information like below output to the Console view. This means the bulk import has completed to the target string collections we specified in Copy String Tables. For simplicity, the importer will copy strings for all locales in a single pass.

If TextManager was able to find pre-translated TEXT.RSC files for a locale, it will import strings from those files. If a TextMappingTable exists for those locales, characters will be automatically remapped back to correct character codes.

Checking Imported Strings

We can now check on our imported strings to make sure everything worked as expected.

  1. Open the Localization Tables editor using Window menu > Asset Management > Localization Tables
  2. Click Selected Table Collection and select Demo_RSC (StringTable).

You should see a fully populated string table collection for all of the locales we configured earlier.

Note the French (fr) and German (de) string tables have been populated by our translated TEXT.RSC files, and accented character codes have been restored. All other locales have been configured with English as a starting point.

You will also notice special RSC markup tags like [/center] and [/end]. These will be covered further in a later tutorial in series.

For now, move on to Localizing Strings in Daggerfall Unity – Part 3.

Posted in Daggerfall Unity, Technical Content, Tutorials.

2 Comments

Comments are closed.