Ejemplo n.º 1
0
        private static void Init()
        {
            if (!_inited)
            {
                _settings = DB.Get <LocalizationSettingsDBEntry>();

                _defaultLanguage = DB.Get <LanguageItem>(_defaultSystemLanguage.ToString());

                var localizationSettingsData = PlayerPrefsLocalData.GetDataNode(LOCALIZATION_SETTINGS_KEY);
                var savedLanguageString      = localizationSettingsData.ContainsKey(LOCALIZATION_SAVED_LANGUAGE_KEY)
                    ? localizationSettingsData.GetString(LOCALIZATION_SAVED_LANGUAGE_KEY)
                    : null;

                if (string.IsNullOrEmpty(savedLanguageString))
                {
                    ChangeLanguage(_currentSystemLanguage.ToString());
                }
                else
                {
                    var savedLanguage = DB.Get <LanguageItem>(savedLanguageString);
                    if (savedLanguage != null)
                    {
                        ChangeLanguage(savedLanguage);
                    }
                    else
                    {
                        Debug.LogWarning(string.Format("Language not found: {0}", savedLanguageString));
                    }
                }

                _inited = true;
            }
        }
        private static void Init()
        {
            if (!_inited)
            {
                _settingsDBEntry = DB.Get <LocalizationSettingsDBEntry>();

                _defaultLanguage = DB.Get <LanguageItem>(_defaultSystemLanguage.ToString());

                var localizationSettingsData = PlayerPrefsLocalData.GetDataNode(LOCALIZATION_SETTINGS_KEY);

                _settings = JSONUtuls.Deserialize <Settings>(localizationSettingsData);

                if (_settings == null)
                {
                    _settings = new Settings();
                }

                if (string.IsNullOrEmpty(_settings.savedLanguage))
                {
                    ChangeLanguage(_currentSystemLanguage.ToString());
                }
                else
                {
                    var savedLanguage = DB.Get <LanguageItem>(_settings.savedLanguage);
                    if (savedLanguage != null)
                    {
                        ChangeLanguage(savedLanguage);
                    }
                    else
                    {
                        Debug.LogWarning(string.Format("Language not found: {0}", _settings.savedLanguage));
                    }
                }

                _inited = true;
            }
        }