Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: apple741 on May 17, 2014, 09:34:01 AM

Title: Key not being found bug
Post by: apple741 on May 17, 2014, 09:34:01 AM
Hello,

I think I have found a bug, I check if my localisation key exists, the if statement below reports false but the debug still prints the correct value?

  1.  
  2. if (Localization.Exists(testString)
  3.                         {
  4.                                 myLabel.text = Localization.Get(testString);
  5.                         }
  6. else
  7.                         {
  8.                                
  9.                                 Debug.Log(Localization.Get(testString);
  10.                         }
  11.  
  12.  
  13.  

Any thoughts on what could be going wrong?
Title: Re: Key not being found bug
Post by: ArenMook on May 17, 2014, 06:42:40 PM
I'm guessing the localization hasn't been loaded yet? Try replacing Localization.Exists with the following:
  1.         static public bool Exists (string key)
  2.         {
  3.                 // Ensure we have a language to work with
  4.                 if (!localizationHasBeenSet) language = PlayerPrefs.GetString("Language", "English");
  5.  
  6. #if UNITY_IPHONE || UNITY_ANDROID
  7.                 string mobKey = key + " Mobile";
  8.                 if (mDictionary.ContainsKey(mobKey)) return true;
  9.                 else if (mOldDictionary.ContainsKey(mobKey)) return true;
  10. #endif
  11.                 return mDictionary.ContainsKey(key) || mOldDictionary.ContainsKey(key);
  12.         }