Ejemplo n.º 1
0
        private void Awake()
        {
            if (string.IsNullOrEmpty(Key))
            {
                return;
            }

            localKey = new LocalKey(Key);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get localization string from a LocalKey,
        /// if localKey is null or localKey cannot found in CurrentStringDatas, return null
        /// otherwise return a localization of localKey (equals to localKey.Value)
        /// NOTE: Don't (and can't) use this method directly, use localKey.Value instead
        /// </summary>
        internal string GetLocalString(LocalKey localKey)
        {
            if (!Initialized)
            {
                Debug.LogWarning($"[{nameof(LocalizationManager)}] Not initialized!");
                return($"{InvalidValue}: <Not initialized>");
            }

            if (localKey == null)
            {
                Debug.LogWarning($"[{nameof(LocalizationManager)}] LocalKey is null! (Language = {currentLanguage.ToString()})");
                return($"{InvalidValue}: <null>");
            }

            if (CurrentStringDatas == null || !CurrentStringDatas.ContainsKey(localKey.Key))
            {
                Debug.LogWarning($"[{nameof(LocalizationManager)}] LocalKey not found! (Language = {currentLanguage.ToString()}, LocalKey = {localKey.Key})");
                return($"{InvalidValue}: {localKey.Key}");
            }

            return(CurrentStringDatas[localKey.Key]);
        }
Ejemplo n.º 3
0
        public LocalKey GetLocalKey(string key)
        {
            if (!Initialized)
            {
                Debug.LogWarning($"[{nameof(LocalizationManager)}] Not initialized!");
                return(InvalidLocalKey);
            }

            if (string.IsNullOrEmpty(key) || null == KeyDatas)
            {
                Debug.LogWarning($"[{nameof(LocalizationManager)}] Key is null!");
                return(InvalidLocalKey);
            }

            if (KeyDatas.ContainsKey(key))
            {
                return(KeyDatas[key]);
            }

            var localKey = new LocalKey(key);

            KeyDatas.Add(key, localKey);
            return(localKey);
        }
Ejemplo n.º 4
0
 public bool Equals(LocalKey obj)
 {
     return(obj != null && obj.GetHashCode() == this.GetHashCode());
 }
Ejemplo n.º 5
0
 public void UpdateKey(LocalKey key)
 {
     localKey = key;
     UpdateText();
 }