Exemplo n.º 1
0
    /// <summary>Called by Dom when the language of the UI changes.
    /// This changes the language of all on screen &variables;.
    /// <see cref="UI.Language"/>.</summary>
    /// <param name="code">The language code/id (e.g. en).</param>
    public static void OnLanguageChange(string code)
    {
        // Get the new language:
        LanguageInfo language = LanguageInfo.Get(code);

        if (language == null)
        {
            // This happens when the localisation system isn't in use at all yet.
            // There's no point going any further.
            return;
        }

        bool goesLeftwards = language.leftwards;

        // For the main UI:
        LanguageChanged(goesLeftwards, document);

        // And all in-world UI's:
        WorldUI worldUI = FirstWorldUI;

        while (worldUI != null)
        {
            LanguageChanged(goesLeftwards, worldUI.document);
            worldUI = worldUI.UIAfter;
        }

        // Re-resolve any already applied UI elements:
        ResolveAllVariables();
    }