Localization

The Dialogue System supports language localization for dialogue databases and also provides general purpose Text Tables.

When you change the language from the default, the Dialogue System will use text from fields that contain localized versions for the specified language.

Localization Package Support: The Dialogue System supports Unity's Localization Package. See Localization Package Integration.

I2 Localization Support: The Dialogue System supports Inter-Illusion's I2 Localization. If you use I2 Localization, you may want to use the Dialogue System's I2 Localization Support.

Localization Services: If you would like to outsource your localization, Pixel Crushers is partnering with localization services to provide easy, economical options to work with professional localization experts. To contact a localization partner, open the Dialogue Editor window. In the Database section > Localization Export/Import foldout, click the Send Localization Request dropdown.

Language Codes

For each localized language, you will use a language code. The codes are up to you, but a good choice is the ISO 639-1 standard: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes.

Example language codes are:

Code Language
es Spanish
ru Russian
fr-CA French (Canadian)

Localizable Dialogue Database Fields

All fields are localizable by adding a blank space and the language code to the field name. The one exception is the Dialogue Text field. For Dialogue Text, use the language code by itself. Set the Type of localized fields to Localization.

The fields below are common ones to localize. If a localized field name is not defined for the current language, it will use the default field.

Commonly-Localized Dialogue Entry Fields

For each language LN, the names of the dialogue entry fields will be:

Default Field Localized Field Example
Dialogue Text LN es
Menu Text Menu Text LN Menu Text es
Sequence Sequence LN Sequence es
Response Menu Sequence Response Menu Sequence LN Response Menu Sequence es

Commonly-Localized Quest Fields

For each language LN, the names of the quest fields will be:

Default Field Localized Field Example
Name Name LN Name es
Description Description LN Description es
Success Description Success Description LN Success Description es
Failure Description Failure Description LN Failure Description es
Entry # Entry # LN Entry 3 es

In Lua code, you can use the GetLocalizedText() Function to get the localized version of a field, which can be useful in dialogue entry Script or Conditions fields or when using [lua(code)] Markup Tags.

Commonly-Localized Actor Fields

If you have ticked Use Display Names, you can set an actor's Display Name. To set localized versions of the Display Name, set these fields:

Default Field Localized Field Example
Display Name Display Name LN Display Name es

How to Localize in the Dialogue Editor

The easiest way to localize using the Dialogue Editor is to add localization fields to the template on the Templates tab. This way, they will automatically be added to assets as you add them.

Follow the instructions below to add localization to a dialogue database.

How to Localize Conversations

These steps demonstrate how to add Spanish (es) and Russian (ru) to conversations.

  1. On the Templates tab, expand the Dialogue Entries foldout.

    • Click the + on the same line as the Dialogue Entries heading to add a field.
    • In the Title, enter the language code.
    • Set the Type to Localization.
    • Select Menu → Apply Template to Assets to apply the changes to all existing dialogue entries.
  2. On the Conversations tab, inspect a dialogue entry node..
    • Add your translations to the the localized fields:

How to Localize Quests

These steps demonstrate how to add Spanish (es) and Russian (ru) to quests.

  1. On the Templates tab, expand the Quests foldout.
    • Click the + on the same line as the Quests heading to add a field.
    • In the Title, enter Description followed by a space and the language code.
    • Set the Type to Localization.
  2. On the Quests tab, inspect a quest.
    • Add your translations to the quest:
  3. To localize quest entries, create custom fields titled Entry n language such as "Entry 1 es".

Dialogue Editor Localization Export/Import Foldout

You can use the Database tab's Localization Export/Import foldout to export separate CSV spreadsheet files for each language. If your database contains quests, each language will generate two files:

  • Dialogue_language.csv: Contains translations for Dialogue Text and Menu Text.
  • Quests_language.csv: Contains translations for quest content.

If your database doesn't contain quests, the Export... button will only generate the Dialogue_language.csv files.

By default, each row in the CSV spreadsheet will identify a line of dialogue by conversation ID (or title) and entry ID. If you want to identify lines of dialogue by unique IDs instead, tick Use Key Field.

  • For articy:draft content, set the key field to: Articy Id
  • For Celtx content, set the key field to: Celtx ID
  • For other content, if your entries don't already have a uniquely-identifying field, you can enter a field name and tick Assign Values to tell the Dialogue System to automatically generate unique field values for any entries that don't already have values.

After exporting CSV files, you can import them into any spreadsheet application such as Microsoft Excel or Google Sheets, or send them to translators. (Translators usually prefer to work with spreadsheets.) Add the translations to each CSV file, and then use the Import... button to import them back into your dialogue database.

Options

If you tick the checkbox next to a language in the Languages list, the Import... button will also import any changes you have made to that language file's main text, not just the language translations.

To export each dialogue entry's conversation title instead of conversation ID, tick the Export Conversation Title checkbox. Conversation titles should be unique in your database.

Normally, the localization foldout looks up each dialogue entry by its conversation ID (or title) + dialogue entry ID. If you want to look up each dialogue entry by a unique dialogue entry field value, tick Use Key Field. This is particularly useful with external import formats such as articy:draft, which assigns a unique Articy Id field value to every dialogue entry.

Dialogue Editor Localization Export/Import Foldout

If you export your database for translation and then make changes to your database before importing the translated CSV files back into the database, please be aware of these rules:

The Localization Export/Import Foldout's Import operation imports quest translations by quest name. If you change the quest name before importing again, the import operation will not find the quest to update its translation. You can add new quests and delete quests without any issues.

The Import operation imports dialogue entries by internal conversation ID (or title) and dialogue entry ID, unless you have ticked Use Key Field. If you change or remove a conversation's dialogue entries before importing again, the translation may not find the correct dialogue entries to update their translations. You can add new dialogue entries or new conversations without any issues.

If you use multiple databases: After you export CSVs, do not use the Unique ID Tool until you have reimported the translations. The Unique ID Tool may change conversation IDs.

Localization in Imported Formats

Chat Mapper, articy:draft, and Aurora Toolset all support localization. For instructions on localizing in these applications, see Import & Export.

Text Tables

The Dialogue System also provides general-purpose, localizable text tables. Text tables are project assets. To create a text table, right-click in the Project view and select Create → Pixel Crushers → Common → Text → Text Table. In the Inspector, click Open Text Table Editor.

Text tables have two tabs:

  • Languages: Let you define the list of languages in this text table.
  • Fields: Contains the text table's entries (fields). Each field has a translation for each language defined on the Languages tab.

Text Table Languages

To add a new language, on the Languages tab click the "+" button. Then enter the name by which you want to refer to the language.

Text Table Fields

To add a new field, on the Fields tab click the "+" button. Enter the field name in the Field column. Then select each language from the dropdown menu in the header of the right column, and enter the field value. You can enter the field value directly into the list row, or you can click on the list row to edit it in a larger text area at the bottom of the window.

By default, if a field value is blank for a language, at runtime the default language's field value will be used. To use the language's blank field value instead of the default language's field value instead, set the static property TextTable.useDefaultLanguageForBlankTranslations to false.

Using Text Tables to Localize UIs

To localize a UI Text element or the options of a Dropdown element, add a Localize UI component. You can assign a Text Table to this component. If none is assigned, it will pull the localized text from the Text Table assigned to the Dialogue Manager.

You can add a UI Localization Manager to the Dialogue Manager to manage and record the current language setting in PlayerPrefs so it's restored when play is resumed. When the scene starts, and whenever you change languages by calling the UILocalizationManager’s UpdateUIs(string language) method, the Localize UI components will look up the values of their field names in the text table and update their text content.

Using Text Tables in Scripts

To get the value of a text table's field in a script, call the text table's GetFieldTextForLanguage method:

var hello = myTextTable.GetFieldTextForLanguage("Hello", "FR");

Text tables have several other helpful methods that you can explore through the online API reference.

How to Localize Alert Messages

To localize gameplay alert messages, assign a text table to the Dialogue Manager's Localization Settings → Text Table.

When the Dialogue System shows an alert, it will first try to use the alert message as a field index into the text table. Otherwise, if the alert message is not a field index in the table, it will just show the alert message itself.

How to Check and Switch Languages

During conversations, if a localized version of a field exists for the current language, the Dialogue System will use it instead of the default version. You can set the current language on the Dialogue Manager object or by script.

How to Check the Current Language

To get the current language, read the Localization.Language property.

How to Switch Languages using the Dialogue Manager

On the Dialogue Manager object, under Localization Settings, set the Language property to the desired language code, or blank to use the default language (i.e., Menu Text instead of Menu Text fr-CA). If you tick Use System Language, then on start the Dialogue System will set the Language property to the current system language.

NOTE: Whenever you specify a language to use, the Dialogue System will store the player's current language selection in a PlayerPrefs key. If set, this will override the Dialogue Manager's Localization Settings > Language value. To reset the key, select Tools → Pixel Crushers → Dialogue System → Tools → Clear Saved Localization Settings.

How to Switch Languages in Scripts

To change the current language, set DialogueManager.SetLanguage. For example:

DialogueManager.SetLanguage("es"); // Use Spanish.

Or, to use .NET enumerations, use the Localization.GetLanguage() method:

DialogueManager.SetLanguage(Localization.GetLanguage(SystemLanguage.Spanish)); // Use Spanish.

How to Switch Languages in Visual Scripting Systems

To set the current language using a visual scripting system such as PlayMaker, use the Set Language action provided by the Dialogue System's support package for that visual scripting system.

Fallback Language

By default, if a localized field is missing or blank, the Dialogue System will use the default language's value. You can change this by setting Localization.UseDefaultIfUndefined to false.

Localization Tools Window

To open the Localization Tools window, select menu item Tools → Pixel Crushers → Dialogue System → Tools → Localization Tools.

The Localization Tools window can copy dialogue databases' Dialogue Text and Menu Text to the primary language fields (e.g., 'Dialogue Text' to 'en' and 'Menu Text' to 'Menu Text en').

Tick Dry Run to print a log of the changes that would be made by the 'Copy to language' button without actually making the changes.

This is often useful in conjunction with I2 Localization Support.

Localized Fonts

To use different fonts for different languages, create a Localized Fonts asset (Assets > Create > Pixel Crushers > Common > UI > Localized Fonts). Assign fonts (Unity Fonts and/or TextMesh Pro Fonts) to use for each language.

Assign your Localized Font asset to the Dialogue Manager's UI Localization Manager component. If your Dialogue Manager doesn't have a UI Localization Manager component, add one.

Then add a Set Localized Font component to any Text or TextMeshProUGUI component, such as your dialogue UI's Subtitle Text GameObjects. This component will switch the Text/TextMeshProUGUI''s font based on the current language. Note: GameObjects with Localize UI components don't need Set Localized Font components.


Localization Package Integration

To enable the Dialogue System's integration with Unity's Localization Package, import Plugins ► Pixel Crushers ► Dialogue System ► Third Party Support ► Localization Package Support.

Localization Package Integration Overview

The Dialogue System's Localization Package integration provides an editor window to help localize dialogue database content and a runtime component named Dialogue System Localization Package Bridge to allow the Dialogue System to retrieve translations from the Localization Package.

At runtime, the Dialogue System Localization Package Bridge will do the following:

  • Set the Dialogue System's Localization.language value to the Localization Package's current locale code whenever the locale changes.
  • Use translations of actor display names, dialogue text, and menu text from the Localized String Table.
  • Set entrytaglocal according the Localization Package's current locale code.

The Dialogue System Localization Package Bridge component must be on the Dialogue Manager or one of the conversation participants since it listens for OnConversationLine methods that are only sent to those GameObjects.

Localization Package Integration Setup

To use the Localization Package integration:

  1. Set up Locales and a String Table Collection according to the Localization Package's instructions.
  2. Select menu item Tools → Pixel Crushers → Dialogue System → Third Party → Localization → Dialogue To Localization Table. This will open the "DS To Loc" window:

    • Assign your dialogue database and the Localization Package's Localization Settings and String Table Collection assets.
    • You can leave the Unique Field Title unchanged. When populating the String Table Collection, the integration will create fields with this title in your database's actors & dialogue entries and assign a unique GUID to each one. The String Table Collection can then refer to the GUID as a unique and persistent value that won't get out of sync if you change your database content.
    • Assign the Default Locale. This is the locale that's used for the default Dialogue Text values in your dialogue database.
  3. Click the "Dialogue To String Table" button to update the String Table Collection.
  4. Add translations to your String Table Collection.
  5. Add a Dialogue System Localization Package Bridge script to your Dialogue Manager GameObject.
    • Assign the Localized String Table and Default Locale assets.
    • Leave the Unique Field Title set to the same value as in the "DS To Loc" window.

The integration localizes quests, but you must use the DS To Loc window's "String Table To Dialogue System" button to reimport the translations back into the dialogue database in order to see the localizations.


<< Welcome to the Dialogue System for Unity! | Scripting >>