> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kodeflowstudios.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Localization

Localization in Parley depends on a few steps, we'll make the example with English but any of the following steps can be done with your own custom languages, see [How To: Add a new language](/parley/how-to/add-new-language).

After adding your own language(s), using them in Parley requires following a few rules.

## Creating the Files

The file that you want to load must be placed in with the parley resource path `Resources/{languageEnglishName}/{folderName}/{langCode}.{fileName}`. For example `Resources/English/SpaceshipLocker/en.Brad`.

<Tabs>
  <Tab title="YAML" icon="code">
    ## Populating the MetaData

    To make Parley use your files semantically and be able to give you useful info about the loaded file, we populate the meta data for our conversation files, whether it is for YAML of Graph. See [YAML MetaData](/parley/reference/yaml-syntax#metadata).

    ## Making the Conversation

    Now write the conversation files in the native script of the language(s) you want to use, we'll be using English and German as seen in the example below:

    ```YAML title="en.Localization" icon="code" theme={null}
    MetaData:
      Language: English
      TextDirection: LTR
    Dialogue:
      node_1:
        Speaker: "Receptionist"
        Text: "Welcome to Pineville Hotel! How may I help you today?"
        NextNode: node_2
      node_2:
        Speaker: "Guest"
        Text: "I want to book a room"
        NextNode: node_3
      node_3:
        Speaker: "Receptionist"
        Text: "Right away! How many nights will you be staying?"
        NextNode: node_4
      node_4:
        Speaker: "Guest"
        Text: "5 nights, and I want a lake side view"
        NextNode: node_5
      node_5:
        Speaker: "Receptionist"
        Text: "Great choice, I'll have that sorted for you right away."
    ```

    ```YAML title="de.Localization" icon="code" theme={null}
    MetaData:
      Language: German
      TextDirection: LTR
    Dialogue:
      node_1:
        Speaker: "Empfangsdame"
        Text: "Willkommen im Pineville Hotel! Wie kann ich Ihnen heute helfen?"
        NextNode: node_2
      node_2:
        Speaker: "Gast"
        Text: "Ich möchte ein Zimmer buchen"
        NextNode: node_3
      node_3:
        Speaker: "Empfangsdame"
        Text: "Sofort! Wie viele Nächte werden Sie bleiben?"
        NextNode: node_4
      node_4:
        Speaker: "Gast"
        Text: "5 Nächte, und ich möchte einen seitlichen Seeblick"
        NextNode: node_5
      node_5:
        Speaker: "Empfangsdame"
        Text: "Gute Wahl, ich werde das sofort für Sie klären lassen."
    ```

    As you can see we set the language and text direction, in the next heading we'll use this data in our script to change the UI.

    ## Making the script

    ```csharp tite="YamlLocalizationUIToolKit.cs" icon="code" theme={null}
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using UnityEngine;
    using KodeFlowStudios.Parley.YamlCore;
    using KodeFlowStudios.Parley.Localization;

    public class YamlLocalizationUIToolKit : MonoBehaviour
    {
    	public UIToolKitHandler uiToolKitHandler;

    	public LanguageID languageToLoad;

    	ParleyYaml parleyYaml;

        void Start()
        {
    		Dialogue();
        }

    	async void Dialogue()
    	{
    		// We pass the optional language parameter so we can choose which language to load.
    		parleyYaml = new ParleyYaml("Examples", "Localization", languageToLoad);

    		if (parleyYaml.Meta.TextDirection == TextDirection.LTR)
    		{
    			uiToolKitHandler.SetTextDirection(false);
    		}
    		else
    		{
    			uiToolKitHandler.SetTextDirection(true);
    		}

    		while (parleyYaml.ConversationEnded != true)
    		{
    			uiToolKitHandler.SetSpeakerNameText(parleyYaml.CurrentNode.Speaker);
    			uiToolKitHandler.SetDialogueText(parleyYaml.CurrentNode.Text);

    			await parleyYaml.OnNextDialogue;
    		}

    		parleyYaml = null;
    	}
    }
    ```
  </Tab>

  <Tab title="Graph" icon="chart-diagram">
    ## Populating the MetaData

    To make Parley use your files semantically and be able to give you useful info about the loaded file, we populate the meta data for our conversation files, whether it is for YAML of Graph. See [Graph Meta Node](/parley/reference/graph-nodes#meta-node).

    ## Making the Conversation

    Now write the conversation files in the native script of the language(s) you want to use, we'll be using English and German as seen in the example below:

    <Frame caption="en.Localization">
      ![English Graph](https://cortado-bucket.lon1.cdn.digitaloceanspaces.com/dohttps://cortado-bucket.lon1.cdn.digitaloceanspaces.com/docs/resources/images/Parley/parley_localization_graph_english.png)
    </Frame>

    <Frame caption="de.Localization">
      ![English Graph](https://cortado-bucket.lon1.cdn.digitaloceanspaces.com/dohttps://cortado-bucket.lon1.cdn.digitaloceanspaces.com/docs/resources/images/Parley/parley_localization_graph_german.png)
    </Frame>

    As you can see we set the language and text direction, in the next heading we'll use this data in our script to change the UI.

    ## Making the script

    ```csharp title="GraphLocalizationUIToolKit.cs" icon="code" theme={null}
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using UnityEngine;
    using KodeFlowStudios.Parley.GraphCore;
    using KodeFlowStudios.Parley.Localization;

    public class GraphLocalizationUIToolKit : MonoBehaviour
    {
    	public UIToolKitHandler uiToolKitHandler;

    	public LanguageID languageToLoad;

    	ParleyGraph parleyGraph;

        void Start()
        {
    		Dialogue();
        }

    	async void Dialogue()
    	{
    		// We pass the optional language parameter so we can choose which language to load.
    		parleyGraph = new ParleyGraph("Examples", "Localization", languageToLoad);

    		if (parleyGraph.Meta.TextDirection == TextDirection.LTR)
    		{
    			uiToolKitHandler.SetTextDirection(false);
    		}
    		else
    		{
    			uiToolKitHandler.SetTextDirection(true);
    		}

    		while (parleyGraph.ConversationEnded != true)
    		{
    			uiToolKitHandler.SetSpeakerNameText(parleyGraph.CurrentNode.Speaker);
    			uiToolKitHandler.SetDialogueText(parleyGraph.CurrentNode.Text);

    			await parleyGraph.OnNextDialogue;
    		}

    		parleyGraph = null;
    	}
    }
    ```
  </Tab>
</Tabs>

<Note>
  Parley handles text with direct string substitution, meaning that you just have to point it to the language and it will use it.
</Note>

## Wiring Things Up

Now connect things as we've done before, select the language from the inspector, and run to see the difference between each selection.
