1
NGUI 3 Support / Request: Localisation reference (e.g. for UIPopupList)
« on: September 12, 2016, 07:50:43 AM »
You have a very nice example for a localization class included in NGUI, but for various reasons I had to roll my own. The UIPopupList (again
) allows to localize the entries, but they statically use Localization.Get(), requiring to override this in a derived class.
I'd like to suggest that we find some kind of centralized reference to the localization which can easily be plugged in and exchanged on demand, and that the static Localization.Get is only used as a fallback. I'm not that tough on patterns, but I believe defining an interface to implement and a static reference on UICamera should do the trick, like so:
I hope that makes sense, if there is a better Pattern to get this done, I'm happy to use that one, I'm not that firm on the details of all available design patterns and their C# implementation
.
) allows to localize the entries, but they statically use Localization.Get(), requiring to override this in a derived class.I'd like to suggest that we find some kind of centralized reference to the localization which can easily be plugged in and exchanged on demand, and that the static Localization.Get is only used as a fallback. I'm not that tough on patterns, but I believe defining an interface to implement and a static reference on UICamera should do the trick, like so:
- interface NGUILocalization {
- public string Get( string key );
- public string[] knownLanguages { public get; }
- public string language { public get; }
- }
- [...]
- public class UICamera {
- [...]
- public static NGUILocalization loca;
- /* Then you could access it like so */
- lbl.text = isLocalized ? UICamera.loca.Get(s) : s;
.



