31
NGUI 3 Support / 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:
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.
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:
- static bool LoadAndSelect (string value)
- {
- if (!string.IsNullOrEmpty(value))
- {
- if (mDictionary.Count == 0 && !LoadDictionary(value)) return false;
- if (SelectLanguage(value)) return true;
- }
- //NEW - If we have loaded an old dictionary we are OK here too
- if(mOldDictionary.Count > 0) {
- return true;
- }
- // Either the language is null, or it wasn't found
- mOldDictionary.Clear();
- mDictionary.Clear(); //NEW - We should probably clear the new dictionary too
- if (string.IsNullOrEmpty(value)) PlayerPrefs.DeleteKey("Language");
- return false;
- }
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.