private void Awake() { if (string.IsNullOrEmpty(Key)) { return; } localKey = new LocalKey(Key); }
/// <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]); }
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); }
public bool Equals(LocalKey obj) { return(obj != null && obj.GetHashCode() == this.GetHashCode()); }
public void UpdateKey(LocalKey key) { localKey = key; UpdateText(); }