GetText() static private method

Gets a translated version of the supplied text message.
static private GetText ( string msgID, string languageCode = null, int lcid = null, bool plural = false ) : string
msgID string Text to be translated
languageCode string Language to translate into
lcid int Specify the Culture LCID for faster access if you know it
plural bool Specify whether you want the plural form of it or not
return string
コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <summary>
        ///     <para>@Alias <c>GetRaw</c> and <c>FormatRaw</c></para>
        ///     <para>Translates the given html applying string.Format(html, arguments.Select(a =&gt; 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 =&gt; 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);
        }
コード例 #4
0
        /// <summary>
        ///     <para>@Alias <c>GetHtml</c> and <c>FormatHtml</c></para>
        ///     <para>Translates the given html applying string.Format(html, arguments.Select(a =&gt; HttpUtility.HtmlEncode(a))) to the current culture language. </para>
        ///     <para>The 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="html">The html to be translated</param>
        /// <param name="arguments">Custom arguments list to be passed to string.Format</param>
        /// <returns>The translated formatted html as MvcHtmlString</returns>
        /// <created author="laurentiu.macovei" date="Fri, 06 Jan 2012 23:49:22 GMT"/>
        public static MvcHtmlString __(this CultureInfo culture, string html, params object[] arguments)
        {
            var result = new MvcHtmlString(string.Format(I18NComplete.GetText(html, lcid: culture.LCID),
                                                         arguments.Select(a => HttpUtility.HtmlEncode(a)).ToArray()));

            return
                (#if DEBUG
                 I18NComplete.OnGetting__(result, culture, html, arguments) ??
#endif
                 result);
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <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 =&gt; 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 =&gt; 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);
        }
コード例 #7
0
        /// <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 =&gt; 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 =&gt; 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);
        }