I saw this post
http://www.tasharen.com/forum/index.php?topic=313.msg1468#msg1468ArenMook said to use an OnLocalize event to change fonts. However, that is not the best solution since it requires a separate script to implement Localize() with every usage of UILabel. And that script will need to hardcode which font goes with what language. BMFont doesn't have the capability to combine fonts, so every localized game that uses non-English characters is going to run into this problem.
As a suggested alternative, I added a singleton class LocalizationFontMap (attached) where you associate a language resource file with a font prefab.
I then changed UILocalize to use the font specified by LocalizationFontMap in the Localize() function.
Original UILocalize :
if (lbl != null)
{
// If this is a label used by input, we should localize its default value instead
UIInput input = NGUITools.FindInParents<UIInput>(lbl.gameObject);
if (input != null && input.label == lbl) input.defaultText = val;
else lbl.text = val;
}
else if (sp != null)
{
sp.spriteName = val;
sp.MakePixelPerfect();
}
Changed UILocalize:
UIFont newFont = null;
if (LocalizationFontMap.instance != null)
{
newFont = LocalizationFontMap.instance.GetCurrentFont();
}
if (lbl != null)
{
// If this is a label used by input, we should localize its default value instead
UIInput input = NGUITools.FindInParents<UIInput>(lbl.gameObject);
if (input != null && input.label == lbl)
{
input.defaultText = val;
}
else
{
if (newFont != null)
lbl.font = newFont;
lbl.text = val;
}
}
else if (sp != null)
{
sp.spriteName = val;
sp.MakePixelPerfect();
}
Let me know if you have suggestions for improvement.