Search Results for

    Show / Hide Table of Contents

    Class LocaleDatabase

    Class for managing locales. This class loads the locales from a backing json file, validates the locales and provides utility methods for handling locales. Each LocaleDatabase can be loaded only once. To load another json, create a new instance.

    Inheritance
    Object
    LocaleDatabase
    Namespace: NoSuchStudio.Localization
    Assembly: NoSuchStudio-Localization.dll
    Syntax
    public class LocaleDatabase
    Remarks

    There are two locale database files included with the Unity package.

    "alllocales.json" contains a large list of all locales (~850). It includes languages like "English" as well as specific locales like "United States English" and "United Kingdom English". This is intended for more in-depth use cases.

    "neutrallocales.json" includes only the neutral locales a.k.a languages. For example there is only "English" in it without the region specifications. This is suitable for most cases.

    Constructors

    LocaleDatabase()

    Declaration
    public LocaleDatabase()

    Fields

    EmptyDatabase

    Declaration
    public static readonly LocaleDatabase EmptyDatabase
    Field Value
    Type Description
    LocaleDatabase

    Properties

    allLocalesByEnglishName

    Returns list of all locales that are curretnly loaded, sorted in ascending alphbetic (a-z) order of their english name.

    Declaration
    public IList<Locale> allLocalesByEnglishName { get; }
    Property Value
    Type Description
    IList<Locale>

    allLocalesByName

    Returns list of all locales that are curretnly loaded, sorted in ascending alphbetic (a-z) order of their name.

    Declaration
    public IList<Locale> allLocalesByName { get; }
    Property Value
    Type Description
    IList<Locale>

    Item[String]

    Retrieve a locale by its code name or english name.

    Declaration
    public Locale this[string locale] { get; }
    Parameters
    Type Name Description
    String locale

    The name of the locale. The name will be normalized. For example any of these ("en" or "EN" or "English" or "english") will return the neutral English locale.

    Property Value
    Type Description
    Locale

    Locale with the given code or english name if one exists, null otherwise.

    neutralLocalesByEnglishName

    Returns list of all neutral locales that are curretnly loaded, sorted in ascending alphbetic (a-z) order of their english name.

    Declaration
    public IList<Locale> neutralLocalesByEnglishName { get; }
    Property Value
    Type Description
    IList<Locale>

    neutralLocalesByName

    Returns list of all neutral locales that are curretnly loaded, sorted in ascending alphbetic (a-z) order of their name.

    Declaration
    public IList<Locale> neutralLocalesByName { get; }
    Property Value
    Type Description
    IList<Locale>

    specificLocalesByEnglishName

    Returns list of all specific locales that are curretnly loaded, sorted in ascending alphbetic (a-z) order of their english name.

    Declaration
    public IList<Locale> specificLocalesByEnglishName { get; }
    Property Value
    Type Description
    IList<Locale>

    specificLocalesByName

    Returns list of all specific locales that are curretnly loaded, sorted in ascending alphbetic (a-z) order of their name.

    Declaration
    public IList<Locale> specificLocalesByName { get; }
    Property Value
    Type Description
    IList<Locale>

    Methods

    ContainsLocale(String)

    Whether the locale database contains a locale.

    Declaration
    public bool ContainsLocale(string localeName)
    Parameters
    Type Name Description
    String localeName

    The code name or english name of the locale. For example any of these ("en", "EN", "English", "english") will return true if the database contain the neutral English locale.

    Returns
    Type Description
    Boolean

    true if a locale with the provided code name or english name exists in the database.

    Dump()

    Declaration
    public void Dump()

    GetLocaleEnglishNamePath(Locale, String)

    Similar to GetLocaleNamePath(Locale, String)

    Declaration
    public string GetLocaleEnglishNamePath(Locale locale, string delimiter = "/")
    Parameters
    Type Name Description
    Locale locale

    Locale to get path for.

    String delimiter

    Delimiter between the locale names.

    Returns
    Type Description
    String

    For English (Australia) it returns: "English/English (Australia)"

    GetLocaleEnglishPathFromCache(Locale)

    Declaration
    public string GetLocaleEnglishPathFromCache(Locale l)
    Parameters
    Type Name Description
    Locale l
    Returns
    Type Description
    String

    GetLocaleNamePath(Locale, String)

    Returns a string with names of locales from the most general to the most specific provided to the call.

    Declaration
    public string GetLocaleNamePath(Locale locale, string delimiter = "/")
    Parameters
    Type Name Description
    Locale locale

    Locale to get path for.

    String delimiter

    Delimiter between the locale names.

    Returns
    Type Description
    String

    For English (Australia) it returns: "en/en-AU"

    GetLocalePathFromCache(Locale)

    Declaration
    public string GetLocalePathFromCache(Locale l)
    Parameters
    Type Name Description
    Locale l
    Returns
    Type Description
    String

    GetNeutralLocale(Locale)

    Declaration
    public Locale GetNeutralLocale(Locale l)
    Parameters
    Type Name Description
    Locale l
    Returns
    Type Description
    Locale

    The neutral locale (i.e. language) for the provided specific locale. If the provided locale is already neutral, it will be returned.

    GetSpecificLocales(Locale, Boolean)

    Declaration
    public List<Locale> GetSpecificLocales(Locale l, bool includeNeutral = false)
    Parameters
    Type Name Description
    Locale l

    The neutral locale (i.e. language) for which to get specific locales.

    Boolean includeNeutral

    if true, the first locale in the list will be the provided neutral locale.

    Returns
    Type Description
    List<Locale>

    All the specific locales for the provided neutral locale.

    HasChildren(Locale)

    Declaration
    public bool HasChildren(Locale l)
    Parameters
    Type Name Description
    Locale l

    query locale

    Returns
    Type Description
    Boolean

    true if locale has child locales, false otherwise.

    NormalizeAndCompare(String, String)

    Declaration
    public static int NormalizeAndCompare(string x, string y)
    Parameters
    Type Name Description
    String x
    String y
    Returns
    Type Description
    Int32
    In This Article
    Back to top Generated by DocFX