Change language manually by <ILocalizationManager>

Posted: 30 Jan 2022 14:07
by MBoy

I'm working on integration with Adventure Creator and Naninovel and
trying to switch Naninovel language manually when a user switched language from Adventure Creator's UI.

With the code below, at first glance it seemd to work without error, but only Managed Text is switched but Script(.nani) remains unchanged.
I would be happy if you could tell me what is wrong!

Code: Select all


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AC;
using Naninovel;

public class CustomScript : MonoBehaviour
{

    void setLanguage (int language)
    {
        int locale = AC.Options.GetLanguage ();
        var naniLocaleManager = Engine.GetService<ILocalizationManager>();

        if (naniLocaleManager != null)
        {

            switch (locale)
            {
                case 0:
                naniLocaleManager.SelectLocaleAsync ("ja");
                break;
            
                case 1:
                naniLocaleManager.SelectLocaleAsync ("en");
                break;
            }
            
        }

    }

    void OnEnable ()
    {
        EventManager.OnChangeLanguage += setLanguage;
    }

    void OnDisable ()
    {
        EventManager.OnChangeLanguage -= setLanguage;
    }


}

Re: Change language manually by <ILocalizationManager>

Posted: 30 Jan 2022 15:10
by Elringus

Check out language dropdown script from the game settings UI. There are additional steps required in case you want to update currently displayed printed text.


Re: Change language manually by <ILocalizationManager>

Posted: 01 Feb 2022 10:25
by MBoy

I checked the script and I guess I understood.
Thanks!