Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Create locales on runtime

Discussion in 'Localization Tools' started by Asianware, May 10, 2023.

  1. Asianware

    Asianware

    Joined:
    Dec 28, 2013
    Posts:
    4
    Hi all,

    I'm already updating the StringTable on runtime and I was wondering if it possible to also create locales on runtime.
    If this is possible, how would I go about creating a locale based on the name or (preferably) code?

    Thanks
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    7,820
    You can call AddLocale.

    E.G

    Code (csharp):
    1. var locale = Locale.CreateLocale("fr");
    2. LocalizationSettings.AvailableLocales.AddLocale(locale);
    You could also do this with a custom ILocalesProvider.
     
    Asianware likes this.
  3. Asianware

    Asianware

    Joined:
    Dec 28, 2013
    Posts:
    4
    That's perfect, thanks!
     
    karl_jones likes this.