Skip to main content

Localization

StoryFlow Editor can export translations for dialogue, choices and authored string values. The Unity plugin reads them from the same imported project as your scripts.

Importing Translations

Set a source language, add target languages and translate text in the StoryFlow Editor. Export the whole project and import it into Unity. The export includes localization.json when target languages are configured. Re-import or use Live Sync after changing translations.

Dialogue titles, dialogue text, text blocks, choices, authored character names and authored String variable values can follow the selected language. This includes String values in script or global arrays and maps. Enum labels, map keys, variable names and values written by game code at runtime remain literal.

Data Assets translate declared String values, including elements in String arrays and values in String maps. Data Asset overrides, enum values and values written during play remain literal.

Switching Language

The manager owns the language for the whole imported project. Build a language picker from GetLanguages(). It returns the source language first, followed by target languages. Each entry has a Code and Name. A project without a localization export returns an empty list.

C#
var manager = StoryFlowManager.Instance;
foreach (var language in manager.GetLanguages())
{
    Debug.Log($"{language.Name}: {language.Code}");
}

bool accepted = manager.SetLanguage("fr");
string current = manager.GetLanguage();

SetLanguage returns false and leaves the current language unchanged for an unknown code. Subscribe to OnLanguageChanged to redraw your own UI when a player switches. StoryFlow Editor text read after the switch uses the new language, including values read during an active dialogue.

C#
void OnEnable()
{
    StoryFlowManager.Instance.OnLanguageChanged += HandleLanguageChanged;
}

void OnDisable()
{
    StoryFlowManager.Instance.OnLanguageChanged -= HandleLanguageChanged;
}

void HandleLanguageChanged(string code)
{
    // Refresh your game's language picker and any cached text.
}

One language for the project

The component's Language Code field does not select a separate language when the imported project has localization. Use StoryFlowManager.SetLanguage for the player's choice.

Keeping the Player Choice

The Unity plugin keeps the selected language for the current session. A plugin save slot stores story state, not language preference. Save the code with your game's settings, then call SetLanguage after the project is assigned at startup. For example, you can use Unity's PlayerPrefs or your existing settings system.

Check your language picker

If GetLanguages() is empty, check that you imported an export containing configured target languages. If a choice is rejected, use one of the returned Code values.

Need Help?

Join our Discord community to ask questions, share your projects, report bugs, and get support from the team and other users.

Join Discord