C# Класс System.Globalization.I18NComplete

The I18NComplete class
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
BasePath string
DefaultWorkingLanguage string
DefaultWorkingLanguageLCID int
HideAllLocalizedText bool
Localizations Localization>.Dictionary

Открытые методы

Метод Описание
GetBestLanguage ( HttpRequest request, string fallback = null ) : string

Spins through the language preferences in the supplied HttpRequest, returning the first complete or partial match on a loaded language.

GetMessage ( string msgID, string languageCode = null, int lcid = null ) : Message

Gets a translated message version of the supplied text message.

LCID ( string cultureName ) : int

Приватные методы

Метод Описание
GetText ( string msgID, string languageCode = null, int lcid = null, bool plural = false ) : string

Gets a translated version of the supplied text message.

I18NComplete ( ) : System.Collections.Generic

Static constructor of I18NComplete

OnGetting_ ( string defaultResult, CultureInfo culture, string text, object arguments ) : string

Throws the Getting_ global event

@Alias _ and GetString

Translates the given text applying string.Format(text, arguments) to the current culture language.

The text and argument values will be HTML Encoded when used in ASP.NET MVC

OnGetting__ ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string html, object arguments ) : System.Web.Mvc.MvcHtmlString

Throws the Getting__ global event

@Alias GetHtml and FormatHtml

Translates the given html applying string.Format(html, arguments.Select(a => HttpUtility.HtmlEncode(a))) to the current culture language.

The html will be kept as it is, while arguments will be automatically HTML Encoded

OnGetting___ ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string html, string>.Func escapeArgumentFunc, object htmlArguments ) : System.Web.Mvc.MvcHtmlString

Throws the Getting___ global event

@Alias GetRaw and FormatRaw

Translates the given html applying string.Format(html, arguments.Select(a => escapeArgumentFunc(a))) to the current culture language.

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

OnGetting___ ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string html, object htmlArguments ) : System.Web.Mvc.MvcHtmlString

Throws the Getting___ global event

@Alias GetRaw and FormatRaw

Translates the given html applying string.Format(html, htmlArguments) to the current culture language.

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

OnGetting___q ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string html ) : System.Web.Mvc.MvcHtmlString

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!

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

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

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

Throws the Getting___s global event

@Alias GetPluralRaw and FormatRawPlural

Translates the given singular or plural HTML applying string.Format(html, arguments) to the current culture language.

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

OnGetting__q ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string html ) : System.Web.Mvc.MvcHtmlString

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, arguments.Select(a => HttpUtility.HtmlEncode(a))))+'"' to the current culture language.

The html will be kept as it is, while arguments will be automatically HTML Encoded

Usage: <input type="submit" value=@__q("Save") /> -- Note the missing quotes!

OnGetting__s ( System.Web.Mvc.MvcHtmlString defaultResult, CultureInfo culture, string singularHTML, string pluralHTML, int count, object arguments ) : System.Web.Mvc.MvcHtmlString

Throws the Getting__s global event

@Alias GetPluralHtml and FormatHtmlPlural

Translates the given singular or plural HTML applying string.Format(html, arguments.Select(a => HttpUtility.HtmlEncode(a))) to the current culture language.

The singular/plural HTML will be kept as it is, while arguments will be automatically HTML Encoded

OnGetting_s ( string defaultResult, CultureInfo culture, string singular, string plural, int count ) : string

Throws the Getting_s global event

@Alias GetPluralString and FormatPlural

Translates the given singular or plural text applying string.Format(text, arguments) to the current culture language.

The singular/plural text and argument values will be HTML Encoded when used in ASP.NET MVC

Описание методов

GetBestLanguage() публичный статический Метод

Spins through the language preferences in the supplied HttpRequest, returning the first complete or partial match on a loaded language.
public static GetBestLanguage ( HttpRequest request, string fallback = null ) : string
request System.Web.HttpRequest
fallback string
Результат string

GetMessage() публичный статический Метод

Gets a translated message version of the supplied text message.
public static GetMessage ( string msgID, string languageCode = null, int lcid = null ) : Message
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
Результат Message

LCID() публичный статический Метод

public static LCID ( string cultureName ) : int
cultureName string
Результат int

Описание свойств

BasePath публичное статическое свойство

This is the base path under which localizations will be stored.
public static string BasePath
Результат string

DefaultWorkingLanguage публичное статическое свойство

The language that MsgIDs are given in (generally the language the project is being developed in).
public static string DefaultWorkingLanguage
Результат string

DefaultWorkingLanguageLCID публичное статическое свойство

The default culture LCID
public static int DefaultWorkingLanguageLCID
Результат int

HideAllLocalizedText публичное статическое свойство

FOR TESTING ONLY! If true, all calls to GetText will return an empty string. this is useful when searching for any strings that might not be flagged for localization.
public static bool HideAllLocalizedText
Результат bool

Localizations публичное статическое свойство

The cached localization
public static Dictionary Localizations
Результат Localization>.Dictionary