System.Globalization.I18NComplete.OnGetting___s C# (CSharp) Method

OnGetting___s() static private method

Throws the Getting___s global event

@Alias GetPluralRaw and FormatRawPlural

Translates the given singular or plural text/html applying string.Format(count == 1 ? singular : plural, arguments.Select(a => escapeArgumentFunc(a))) to the current culture language.

For each argument the escape func will be called before applying the format

static private OnGetting___s ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string singularHTML, string pluralHTML, int count, string>.Func escapeArgumentFunc, object htmlArguments ) : 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
singularHTML string The text/HTML to be translated when count is 1
pluralHTML string The text/HTML to be translated when count is NOT 1
count int If count is 1 the singular text/HTML will be used, otherwise the plural text
escapeArgumentFunc string>.Func The func to be applied for each argument .i.e. a => HttpUtility.HtmlAttributeEncode(a)
htmlArguments object The text/HTML arguments to be applied. For each argument will apply the escape func!
return System.Web.Mvc.MvcHtmlString
        internal static MvcHtmlString OnGetting___s(MvcHtmlString defaultResult, CultureInfo culture, string singularHTML, string pluralHTML, int count, Func<object, string> escapeArgumentFunc, object[] htmlArguments)
        {
            if (Getting___se != null)
                return Getting___se(defaultResult, culture, singularHTML, pluralHTML, count, escapeArgumentFunc, htmlArguments);
            return null;
        }

Same methods

I18NComplete::OnGetting___s ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string singularHTML, string pluralHTML, int count, object htmlArguments ) : System.Web.Mvc.MvcHtmlString

Usage Example

Beispiel #1
0
        /// <summary>
        ///     <para>@Alias <c>GetPluralRaw</c> and <c>FormatRawPlural</c></para>
        ///     <para>Translates the given singular or plural HTML applying string.Format(html, arguments) to the current culture language. </para>
        ///     <para>Warning! Neither the html nor the htmlArguments will be encoded whatsoever</para>
        /// </summary>
        /// <param name="culture">The culture being extended</param>
        /// <param name="singularHTML">The HTML to be translated when count is 1</param>
        /// <param name="pluralHTML">The HTML to be translated when count is NOT 1</param>
        /// <param name="count">If count is 1 the singular HTML will be used, otherwise the plural HTML</param>
        /// <param name="htmlArguments">The html arguments to be applied. Warning! The arguments will not be htmlEncoded!</param>
        /// <returns>The translated formatted HTML as MvcHtmlString</returns>
        public static MvcHtmlString ___s(this CultureInfo culture, string singularHTML, string pluralHTML, int count, params object[] htmlArguments)
        {
            var result = new MvcHtmlString(
                ((htmlArguments == null || htmlArguments.Length == 0)
                ? string.Format(count == 1 ? I18NComplete.GetText(singularHTML, lcid: culture.LCID) : I18NComplete.GetText(singularHTML, plural: true, lcid: culture.LCID), count)
                : string.Format(count == 1 ? I18NComplete.GetText(singularHTML, lcid: culture.LCID) : I18NComplete.GetText(singularHTML, plural: true, lcid: culture.LCID), new object[] { count }.Concat(htmlArguments).ToArray())));

            return
                (#if DEBUG
                 I18NComplete.OnGetting___s(result, culture, singularHTML, pluralHTML, count, htmlArguments) ??
#endif
                 result);
        }