Author Topic: 3.5.8 Old-Style Localization Bug  (Read 1619 times)

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
3.5.8 Old-Style Localization Bug
« on: April 21, 2014, 11:02:47 AM »
Hi ArenMook,

I noticed that there is a bug when using the old key=value localization approach. In the SelectLanguage() in UILocalize it only checks the "new" dictionary instead of mOldDictionary. So, we should also probably check the old dictionary size before cleaning up and returning null.

I think it should check both, maybe something similar to this:

  1.         static bool LoadAndSelect (string value)
  2.         {
  3.                 if (!string.IsNullOrEmpty(value))
  4.                 {
  5.                         if (mDictionary.Count == 0 && !LoadDictionary(value)) return false;
  6.                         if (SelectLanguage(value)) return true;
  7.                 }
  8.  
  9.                 //NEW - If we have loaded an old dictionary we are OK here too
  10.                 if(mOldDictionary.Count > 0) {
  11.                         return true;
  12.                 }
  13.  
  14.                 // Either the language is null, or it wasn't found
  15.                 mOldDictionary.Clear();
  16.                 mDictionary.Clear(); //NEW - We should probably clear the new dictionary too
  17.                 if (string.IsNullOrEmpty(value)) PlayerPrefs.DeleteKey("Language");
  18.                 return false;
  19.         }
  20.  


Are you planning on removing the Key=Value localization in the future? Our games can use thousands of keys and loading all of the languages associated with these keys in the dictionary would use unnecessary RAM and increase the size of the GC heap (thus reducing GC performance). Keeping the lower overhead Key=Value suits our needs better, but if it's going to be inevitable I guess I'd like to know so we can go through the process now.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.5.8 Old-Style Localization Bug
« Reply #1 on: April 22, 2014, 04:21:52 AM »
I don't plan on removing the old style system. I'd like to phase it out, but I still want it to be supported for older projects. Plus... if you use Localization.Set to manually set the dictionary it will still use the old style dictionary, so I want it to work. Thanks for bringing this to my attention, I'll add your change to the repo.