System.Globalization.I18NComplete.OnGetting___q C# (CSharp) Метод

OnGetting___q() статический приватный Метод

Throws the Getting___q global event

Quotes the text as the xgettext cannot correctly extract values from attributes

Translates the given html applying '"'+HttpUtility.HtmlAttributeEncode(string.Format(html, htmlArguments))+'"' to the current culture language.

Warning! Neither the html nor the htmlArguments will be encoded whatsoever

Usage: <div title=@___q("< class='tip'>There are {0} {1} in cart.</div>", 3, "<b>Items</b>")>... -- Note the missing quotes!

static private OnGetting___q ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string html ) : System.Web.Mvc.MvcHtmlString
defaultResult System.Web.Mvc.MvcHtmlString The I18NComplete default result. Returning null will fallback on this result, otherwise return a custom value to oveerride this.
culture CultureInfo The culture this translation is being translated
html string The html to be translated
Результат System.Web.Mvc.MvcHtmlString
        internal static MvcHtmlString OnGetting___q(MvcHtmlString defaultResult, CultureInfo culture, string html, params object[] htmlArguments)
        {
            if (Getting___q != null)
                return Getting___q(defaultResult, culture, html, htmlArguments);
            return null;
        }

Usage Example

Пример #1
0
        /// <summary>
        ///     <para>Quotes the text as the xgettext cannot correctly extract values from attributes</para>
        ///     <para>Translates the given html applying '"'+HttpUtility.HtmlAttributeEncode(string.Format(html, htmlArguments))+'"' to the current culture language. </para>
        ///     <para>Warning! Neither the html nor the htmlArguments will be encoded whatsoever</para>
        ///     <para>Usage: &lt;div title=@___q("&lt; class='tip'&gt;There are {0} {1} in cart.&lt;/div&gt;", 3, "&lt;b&gt;Items&lt;/b&gt;")&gt;...  -- Note the missing quotes!</para>
        /// </summary>
        /// <param name="culture">The culture being extended</param>
        /// <param name="html">The html text to be translated</param>
        /// <param name="htmlArguments">Custom arguments list to be passed to string.Format</param>
        /// <returns>The translated formatted html as MvcHtmlString</returns>
        /// <created author="laurentiu.macovei" date="Fri, 13 Jan 2012 03:55:43 GMT"/>
        public static MvcHtmlString ___q(this CultureInfo culture, string html, params object[] htmlArguments)
        {
            var result = new MvcHtmlString('"' + HttpUtility.HtmlAttributeEncode(string.Format(I18NComplete.GetText(html, lcid: culture.LCID), htmlArguments.Select(a => HttpUtility.HtmlEncode(a)).ToArray())) + '"');

            return
                (#if DEBUG
                 I18NComplete.OnGetting___q(result, culture, html, htmlArguments) ??
#endif
                 result);
        }