Localizations and Assets
Localization is the process of translating and adapting content to a specific language, region or culture.
Yarn scripts are written in human-readable language. This is generally a single language, and (most of the time) will be written in the language that your development team primarily speaks. The language that a Yarn project is written in is called the base language.
However, if you want your dialogue to be understood by people who don't speak this language, you will need to translate it. Yarn Spinner is designed to make it easy to extract the user-facing text of your dialogue into a strings file, which can then be translated into a different language, and then loaded at run-time. You can translate your project into as many languages as you'd like, and Yarn Spinner will handle it for you automatically.
Yarn Spinner is also designed around the idea that a line of dialogue may have assets associated with it. Most commonly, this means an audio file that contains an actor performing the line, so that it can be used in your game as a voice-over. These assets are also localisable.
- Localisation: A set of information that describes where to find text and assets for a given language.
- Base language: The language that your Yarn script files are written in.
- Strings file: A text document that contains translated versions of Yarn lines.
- Line ID: A unique code that identifies a line of dialogue or an option in the original source text.
- Localised line: The text of a line of dialogue, in a particular locale.
- Localised line asset: An asset (for example, an audio clip) that's associated for a particular line, in a particular locale. For example, an audio clip containing the voiceover for the line "Hello there", in German.
In Yarn Spinner, the localisation workflow works like this:
- 1.Write your Yarn scripts. This original content is your 'base' localisation.
- 2.Add a line ID to each line of dialogue in your script.
- 3.Set up localisations in the Yarn Project for each of the languages you wish to support. (This includes your base language.)
- 4.For each localisation besides your base language:
- 1.Export a strings file.
- 2.Translate its contents into another language.
- 3.Associate the strings file with the localisation.
- 5.If you have assets you want to use with your dialogue, associate the folder that contains those assets with the localisation they belong to, and set up a Line Provider that's able to use those assets (such as an Audio Line Provider.)
In the following sections, we'll go through each of these steps.
Every Yarn script is associated with a base language. By default, Yarn Spinner sets the base language to that of your current locale. For example, if your computer is set to use Australian English, then Yarn Spinner will use that as the base language.
The base language of a Yarn Script is controlled by the Yarn Project that it's a part of. You can change the language of your base localisation by changing the 'Base Language' setting on a Yarn Project.
In order to match different versions of a line, you need to add a line id to each line of dialogue. A line ID is a tag that appears at the end of a line that uniquely identifies a line of dialogue in your game.
Here's an example of a line of dialogue with a line tag:
Gunther: I wanted orange! They gave me lemon-lime. #line:1a64a5
In this example, the line of dialogue has a line ID of
Yarn Spinner can add line IDs to your dialogue for you. To do this, select your Yarn Project, and click 'Add Line Tags to Scripts'. Yarn Spinner will re-write all of the script files, adding a line ID to any line that doesn't already have one.
Once you've added line IDs to your Yarn scripts, they're ready to be used in your game's localisation system. Yarn Spinner provides a built-in localisation system, which is described in Built Yarn Spinner localisation system