예제 #1
0
        private static void ApplyLanguage(Control control, ILocalizedLanguage lang)
        {
            var  tag    = control.Tag?.ToString();
            bool hasTag = tag?.StartsWith("iatag_") ?? false;

            if (hasTag)
            {
                var localizedTag = lang.GetTag(tag);
                if (!string.IsNullOrEmpty(localizedTag))
                {
                    control.Text = localizedTag;
                }
                else if (lang.WarnIfMissing)
                {
                    Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tag,
                                      control.Text);
                }
            }
            else
            {
                // Listview column headers
                ListView lv = control as ListView;
                if (lv != null)
                {
                    foreach (ColumnHeader header in lv.Columns)
                    {
                        ApplyLanguage(header, lang);
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Recursively check each control for .Tag == "iatag_*"
 /// If the tag is located and also found in the provided language pack, the controls text is updated
 /// </summary>
 /// <param name="c"></param>
 /// <param name="lang"></param>
 public static void ApplyLanguage(Control.ControlCollection c, ILocalizedLanguage lang)
 {
     foreach (Control control in c)
     {
         ApplyLanguage(control, lang);
         ApplyLanguage(control.Controls, lang);
     }
 }
예제 #3
0
        private static void ApplyLanguage(Control control, ILocalizedLanguage lang, ToolTip toolTip = null)
        {
            var  tag    = control.Tag?.ToString();
            bool hasTag = tag?.StartsWith("iatag_") ?? false;

            if (hasTag)
            {
                // Some controls like TextBox will only have a _tooltip tag, don't insert the text into them.
                if (!tag.EndsWith("_tooltip"))
                {
                    var localizedTag = lang.GetTag(tag);
                    if (!string.IsNullOrEmpty(localizedTag))
                    {
                        control.Text = localizedTag;
                    }
                    else if (lang.WarnIfMissing)
                    {
                        Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tag, control.Text);
                    }
                }

                // Most controls only has a regular tag, but may contain a _tooltip tag too.
                if (toolTip != null && !string.IsNullOrEmpty(toolTip.GetToolTip(control)))
                {
                    var tooltipTagName = (tag + "_tooltip").Replace("_tooltip_tooltip", "_tooltip");

                    var localizedTooltipTag = lang.GetTag(tooltipTagName);
                    if (!string.IsNullOrEmpty(localizedTooltipTag))
                    {
                        toolTip.SetToolTip(control, localizedTooltipTag);
                    }
                    else if (lang.WarnIfMissing)
                    {
                        Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tooltipTagName, toolTip.GetToolTip(control));
                    }
                }
            }
            else
            {
                // Listview column headers
                ListView lv = control as ListView;
                if (lv != null)
                {
                    foreach (ColumnHeader header in lv.Columns)
                    {
                        ApplyLanguage(header, lang);
                    }
                }
            }
        }
예제 #4
0
        public static string Translate(ILocalizedLanguage language, string stat)
        {
            if (SlotMap == null)
            {
                SlotMap = new Dictionary <string, string>();

                SlotMap["ArmorProtective_Head"]      = language.GetTag("iatag_slot_head");
                SlotMap["ArmorProtective_Hands"]     = language.GetTag("iatag_slot_hands");
                SlotMap["ArmorProtective_Feet"]      = language.GetTag("iatag_slot_feet");
                SlotMap["ArmorProtective_Legs"]      = language.GetTag("iatag_slot_legs");
                SlotMap["ArmorProtective_Chest"]     = language.GetTag("iatag_slot_chest");
                SlotMap["ArmorProtective_Waist"]     = language.GetTag("iatag_slot_belt");
                SlotMap["ArmorJewelry_Medal"]        = language.GetTag("iatag_slot_medal");
                SlotMap["ArmorJewelry_Ring"]         = language.GetTag("iatag_slot_ring");
                SlotMap["ArmorProtective_Shoulders"] = language.GetTag("iatag_slot_shoulder");
                SlotMap["ArmorJewelry_Amulet"]       = language.GetTag("iatag_slot_neck");

                SlotMap["WeaponMelee_Dagger"]  = language.GetTag("iatag_slot_dagger1h");
                SlotMap["WeaponMelee_Mace"]    = language.GetTag("iatag_slot_mace1h");
                SlotMap["WeaponMelee_Axe"]     = language.GetTag("iatag_slot_axe1h");
                SlotMap["WeaponMelee_Scepter"] = language.GetTag("iatag_slot_scepter1h");
                SlotMap["WeaponMelee_Sword"]   = language.GetTag("iatag_slot_sword1h");

                SlotMap["WeaponMelee_Sword2h"] = language.GetTag("iatag_slot_sword2h");
                SlotMap["WeaponMelee_Mace2h"]  = language.GetTag("iatag_slot_mace2h");
                SlotMap["WeaponMelee_Axe2h"]   = language.GetTag("iatag_slot_axe2h");

                SlotMap["WeaponHunting_Ranged1h"] = language.GetTag("iatag_slot_ranged1h");
                SlotMap["WeaponHunting_Ranged2h"] = language.GetTag("iatag_slot_ranged2h");

                SlotMap["WeaponArmor_Offhand"] = language.GetTag("iatag_slot_offhand");
                SlotMap["WeaponArmor_Shield"]  = language.GetTag("iatag_slot_shield");
                SlotMap["ItemRelic"]           = language.GetTag("iatag_slot_component");
                SlotMap["ItemArtifact"]        = language.GetTag("iatag_slot_relic");
                SlotMap["ItemFactionBooster"]  = language.GetTag("iatag_slot_scroll");
                SlotMap["ItemEnchantment"]     = language.GetTag("iatag_slot_augmentation");
            }



            if (!string.IsNullOrEmpty(stat) && SlotMap.ContainsKey(stat))
            {
                return(SlotMap[stat]);
            }
            else
            {
                return(stat);
            }
        }
예제 #5
0
        private static void ApplyLanguage(ColumnHeader control, ILocalizedLanguage lang)
        {
            var  tag    = control.Tag?.ToString();
            bool hasTag = tag?.StartsWith("iatag_") ?? false;

            if (hasTag)
            {
                var localizedTag = lang.GetTag(tag);
                if (!string.IsNullOrEmpty(localizedTag))
                {
                    control.Text = localizedTag;
                }
                else if (lang.WarnIfMissing)
                {
                    Logger.WarnFormat("Could not find tag {0} in localization, defaulting to {0}={1}", tag,
                                      control.Text);
                }
            }
        }
예제 #6
0
        public static string TranslateFaction(ILocalizedLanguage language, string faction)
        {
            switch (faction)
            {
            case "Survivors":
                return(language.GetTag("tagFactionSurvivors"));

            case "User0":
                return(language.GetTag("tagFactionUser0"));

            case "User2":
                return(language.GetTag("tagFactionUser2"));

            case "User4":
                return(language.GetTag("tagFactionUser4"));

            case "User5":
                return(language.GetTag("tagFactionUser5"));

            case "User7":
                return(language.GetTag("tagFactionUser7"));

            case "User8":
                return(language.GetTag("tagFactionUser8"));

            case "User9":
                return(language.GetTag("tagFactionUser9_ia"));

            case "User10":
                return(language.GetTag("tagFactionUser10_ia"));

            case "User11":
                return(language.GetTag("tagFactionUser11_ia"));

            default:
                return(faction);
            }
        }
예제 #7
0
 public StatManager(ILocalizedLanguage language)
 {
     _language = language;
 }
예제 #8
0
 public static void ApplyTooltipLanguage(ToolTip toolTip, Control.ControlCollection c, ILocalizedLanguage lang)
 {
     foreach (Control control in c)
     {
         ApplyLanguage(control, lang, toolTip);
         ApplyTooltipLanguage(toolTip, control.Controls, lang);
     }
 }