Пример #1
0
        /// <summary>
        /// Allows the BetterToolTip to give L10NSharp the information it needs to put strings
        /// into the localization UI to be localized.
        /// </summary>
        /// <returns>A list of LocalizingInfo objects</returns>
        public IEnumerable <LocalizingInfo> GetAllLocalizingInfoObjects(L10NSharpExtender extender)
        {
            var result = new List <LocalizingInfo>();

            foreach (var ctrl in m_allControlsHavingToolTips)
            {
                var idPrefix  = extender.GetLocalizingId(ctrl);
                var normalTip = GetToolTip(ctrl);
                if (!string.IsNullOrEmpty(normalTip))
                {
                    var liNormal = new LocalizingInfo(ctrl, idPrefix + NORMAL_TIP)
                    {
                        Text = normalTip, Category = LocalizationCategory.LocalizableComponent
                    };
                    result.Add(liNormal);
                }
                var disabledTip = GetToolTipWhenDisabled(ctrl);
                if (!string.IsNullOrEmpty(disabledTip))
                {
                    var liDisabled = new LocalizingInfo(ctrl, idPrefix + DISABLED_TIP)
                    {
                        Text = disabledTip, Category = LocalizationCategory.LocalizableComponent
                    };
                    result.Add(liDisabled);
                }
            }
            return(result);
        }
        /// <summary>
        /// Allows the MockLocalizableComponent to give L10NSharp the information it needs to put strings
        /// into the localization UI to be localized.
        /// </summary>
        /// <returns>A list of LocalizingInfo objects</returns>
        public IEnumerable <LocalizingInfo> GetAllLocalizingInfoObjects(L10NSharpExtender extender)
        {
            var result = new List <LocalizingInfo>();

            foreach (var kvp in StringContainer)
            {
                var control = kvp.Key.Item1;
                var id      = extender.GetLocalizingId(control) + kvp.Key.Item2;
                result.Add(new LocalizingInfo(control, id)
                {
                    Text = kvp.Value, Category = LocalizationCategory.LocalizableComponent
                });
            }
            return(result);
        }
        public void GetSetTests()
        {
            Assert.AreEqual(0, m_extCtrls.Count);

            var lbl = new Label();

            m_extender.SetLocalizableToolTip(lbl, "lions");
            m_extender.SetLocalizationComment(lbl, "tigers");
            m_extender.SetLocalizingId(lbl, "bears");
            m_extender.SetLocalizationPriority(lbl, LocalizationPriority.MediumLow);

            Assert.AreEqual(1, m_extCtrls.Count);
            Assert.AreEqual("lions", m_extender.GetLocalizableToolTip(lbl));
            Assert.AreEqual("tigers", m_extender.GetLocalizationComment(lbl));
            Assert.AreEqual("bears", m_extender.GetLocalizingId(lbl));
            Assert.AreEqual(LocalizationPriority.MediumLow, m_extender.GetLocalizationPriority(lbl));
        }
Пример #4
0
 /// <summary>
 /// Allows the BetterToolTip to give L10NSharp the information it needs to put strings
 /// into the localization UI to be localized.
 /// </summary>
 /// <returns>A list of LocalizingInfo objects</returns>
 public IEnumerable<LocalizingInfo> GetAllLocalizingInfoObjects(L10NSharpExtender extender)
 {
     var result = new List<LocalizingInfo>();
     foreach (var ctrl in _allControlsHavingToolTips)
     {
         var idPrefix = extender.GetLocalizingId(ctrl);
         var normalTip = GetToolTip(ctrl);
         if (!string.IsNullOrEmpty(normalTip))
         {
             var liNormal = new LocalizingInfo(ctrl, idPrefix + NORMAL_TIP)
                 { Text = normalTip, Category = LocalizationCategory.LocalizableComponent };
             result.Add(liNormal);
         }
         var disabledTip = GetToolTipWhenDisabled(ctrl);
         if (!string.IsNullOrEmpty(disabledTip))
         {
             var liDisabled = new LocalizingInfo(ctrl, idPrefix + DISABLED_TIP)
                 { Text = disabledTip, Category = LocalizationCategory.LocalizableComponent };
             result.Add(liDisabled);
         }
     }
     return result;
 }