/// <summary> /// <para>@Alias <c>GetString</c> and <c>Format</c></para> /// <para>Translates the given text applying string.Format(text, arguments) to the current culture language. </para> /// <para>The text and argument values will be HTML Encoded when used in ASP.NET MVC</para> /// </summary> /// <param name="culture">The culture being extended</param> /// <param name="text">The text to be translated</param> /// <param name="arguments">Custom arguments list to be passed to string.Format</param> /// <returns>The translated formatted text as string</returns> /// <created author="laurentiu.macovei" date="Fri, 06 Jan 2012 23:47:10 GMT"/> public static string _(this CultureInfo culture, string text, params object[] arguments) { var result = string.Format(I18NComplete.GetText(text, lcid: culture.LCID), arguments); return (#if DEBUG I18NComplete.OnGetting_(result, culture, text, arguments) ?? #endif result); }
/// <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: <div title=@___q("< class='tip'>There are {0} {1} in cart.</div>", 3, "<b>Items</b>")>... -- 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); }
/// <summary> /// <para>@Alias <c>GetRaw</c> and <c>FormatRaw</c></para> /// <para>Translates the given html applying string.Format(html, htmlArguments) 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="html">The html to be translated</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> /// <created author="laurentiu.macovei" date="Fri, 06 Jan 2012 23:46:39 GMT"/> public static MvcHtmlString ___(this CultureInfo culture, string html, params object[] htmlArguments) { var result = new MvcHtmlString(string.Format(I18NComplete.GetText(html, lcid: culture.LCID), htmlArguments)); return (#if DEBUG I18NComplete.OnGetting___(result, culture, html, htmlArguments) ?? #endif result); }
/// <summary> /// <para>@Alias <c>GetRaw</c> and <c>FormatRaw</c></para> /// <para>Translates the given html applying string.Format(html, arguments.Select(a => escapeArgumentFunc(a))) to the current culture language. </para> /// <para>For each argument the escape func will be called before applying the format</para> /// </summary> /// <param name="culture">The culture being extended</param> /// <param name="html">The text to be translated</param> /// <param name="htmlArguments">The html arguments to be applied. For each argument will apply the escape func!</param> /// <param name="escapeArgumentFunc">The func to be applied for each argument .i.e. <c>a => HttpUtility.HtmlAttributeEncode(a)</c></param> /// <returns>The translated formatted html as MvcHtmlString</returns> /// <created author="laurentiu.macovei" date="Fri, 06 Jan 2012 23:46:56 GMT"/> public static MvcHtmlString ___(this CultureInfo culture, string html, Func <object, string> escapeArgumentFunc, params object[] htmlArguments) { var result = new MvcHtmlString(string.Format(I18NComplete.GetText(html, lcid: culture.LCID), htmlArguments .Select(a => escapeArgumentFunc(a)).ToArray())); return (#if DEBUG I18NComplete.OnGetting___(result, CultureInfo.CurrentCulture, html, escapeArgumentFunc, htmlArguments) ?? #endif result); }
/// <summary> /// <para>@Alias <c>GetPluralString</c> and <c>FormatPlural</c></para> /// <para>Translates the given singular or plural text applying string.Format(text, arguments) to the current culture language. </para> /// <para>The singular/plural text and argument values will be HTML Encoded when used in ASP.NET MVC</para> /// </summary> /// <param name="culture">The culture being extended</param> /// <param name="singular">The text to be translated when count is 1</param> /// <param name="plural">The text to be translated when count is NOT 1</param> /// <param name="count">If count is 1 the singular text will be used, otherwise the plural text</param> /// <param name="arguments">Custom arguments list to be passed to string.Format</param> /// <returns>The translated formatted text as string</returns> /// <created author="laurentiu.macovei" date="Fri, 06 Jan 2012 23:21:19 GMT"/> public static string _s(this CultureInfo culture, string singular, string plural, int count, params object[] arguments) { var result = ((arguments == null || arguments.Length == 0) ? string.Format(count == 1 ? I18NComplete.GetText(singular, lcid: culture.LCID) : I18NComplete.GetText(singular, plural: true, lcid: culture.LCID), count) : string.Format(count == 1 ? I18NComplete.GetText(singular, lcid: culture.LCID) : I18NComplete.GetText(singular, plural: true, lcid: culture.LCID), new object[] { count }.Concat(arguments).ToArray())); return (#if DEBUG I18NComplete.OnGetting_s(result, culture, singular, plural, count, arguments) ?? #endif result); }
/// <summary> /// <para>@Alias <c>GetPluralHtml</c> and <c>FormatHtmlPlural</c></para> /// <para>Translates the given singular or plural HTML applying string.Format(html, arguments.Select(a => HttpUtility.HtmlEncode(a))) to the current culture language. </para> /// <para>The singular/plural HTML will be kept as it is, while arguments will be automatically HTML Encoded</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 text</param> /// <param name="arguments">The arguments to be applied as arguments.Select(a => HttpUtility.HtmlEncode(a))</param> /// <returns>The translated formatted HTML as MvcHtmlString</returns> /// <created author="laurentiu.macovei" date="Fri, 06 Jan 2012 23:24:19 GMT"/> public static MvcHtmlString __s(this CultureInfo culture, string singularHTML, string pluralHTML, int count, params object[] arguments) { var result = new MvcHtmlString( (arguments == null || arguments.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(arguments.Select(a => HttpUtility.HtmlEncode(a))).ToArray())); return (#if DEBUG I18NComplete.OnGetting__s(result, culture, singularHTML, pluralHTML, count, arguments) ?? #endif result); }
/// <summary> /// <para>@Alias <c>GetPluralRaw</c> and <c>FormatRawPlural</c></para> /// <para>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. </para> /// <para>For each argument the escape func will be called before applying the format</para> /// </summary> /// <param name="culture">The culture being extended</param> /// <param name="singularHTML">The text/HTML to be translated when count is 1</param> /// <param name="pluralHTML">The text/HTML to be translated when count is NOT 1</param> /// <param name="count">If count is 1 the singular text/HTML will be used, otherwise the plural text</param> /// <param name="htmlArguments">The text/HTML arguments to be applied. For each argument will apply the escape func!</param> /// <param name="escapeArgumentFunc">The func to be applied for each argument .i.e. <c>a => HttpUtility.HtmlAttributeEncode(a)</c></param> /// <returns>The translated formatted text/HTML as MvcHtmlString</returns> /// <created author="laurentiu.macovei" date="Thu, 24 Nov 2011 20:09:53 GMT"/> public static MvcHtmlString ___s(this CultureInfo culture, string singularHTML, string pluralHTML, int count, Func <object, string> escapeArgumentFunc, 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), escapeArgumentFunc(count)) : string.Format(count == 1 ? I18NComplete.GetText(singularHTML, lcid: culture.LCID) : I18NComplete.GetText(singularHTML, plural: true, lcid: culture.LCID), new object[] { escapeArgumentFunc(count) }.Concat(htmlArguments.Select(a => escapeArgumentFunc(a))).ToArray()))); return (#if DEBUG I18NComplete.OnGetting___s(result, culture, singularHTML, pluralHTML, count, escapeArgumentFunc, htmlArguments) ?? #endif result); }