Пример #1
0
    public static void SetRegion(enum_Option_LanguageRegion location)
    {
        if (e_CurLocation == location)
        {
            return;
        }

        e_CurLocation = location;

        List <string[]> data = TExcel.Tools.ReadExcelFirstSheetData(TResources.GetExcelData("SLocalization"));

        for (int i = 1; i < data[0].Length; i++)
        {
            if (data[0][i] != ((enum_Option_LanguageRegion)i).ToString())
            {
                Debug.LogError("SLocalizataion Not Init Propertly:" + i.ToString());
            }
        }

        CurLocalization.Clear();
        int localizeIndex = (int)e_CurLocation;

        for (int i = 0; i < data.Count; i++)
        {
            CurLocalization.Add(data[i][0], data[i][localizeIndex]);
        }
        OnLocaleChanged?.Invoke();
        IsInit = true;
    }
Пример #2
0
        /// <summary>
        /// Switches the application to the specified culture
        /// <param name="culture">The culture to switch to</param>
        /// <returns>bool - if the culture was switched to successfully</returns>
        /// </summary>
        public static bool SwitchCulture(string culture)
        {
            var loadedTable = LoadLocalisationTable(culture);

            if (loadedTable == null)
            {
                Debug.LogWarning(string.Format("Error loading localisation table for locale: {0}", culture));
                return(false);
            }

            CurrentLocale            = new CultureInfo(culture);
            currentLocalisationTable = loadedTable;

            if (OnLocaleChanged != null)
            {
                OnLocaleChanged.Invoke();
            }

            return(true);
        }
Пример #3
0
        public virtual async UniTask SelectLocaleAsync(string locale)
        {
            if (!LocaleAvailable(locale))
            {
                Debug.LogWarning($"Failed to select locale: Locale `{locale}` is not available.");
                return;
            }

            if (locale == SelectedLocale)
            {
                return;
            }

            SelectedLocale = locale;

            foreach (var task in changeLocaleTasks)
            {
                await task();
            }

            OnLocaleChanged?.Invoke(SelectedLocale);
        }