C# 클래스 i18n.HttpContextExtensions

파일 보기 프로젝트 열기: turquoiseowl/i18n

공개 메소드들

메소드 설명
ChooseAppLanguage ( this context, IEnumerable AppLanguages ) : LanguageTag

Runs the Language Matching Algorithm for the UserLanguages of the current request against the specified array of AppLanguages, returning the AppLanguage determined to be the best match.

GetHttpContextBase ( this context ) : System.Web.HttpContextBase

Returns an System.Web.HttpContextBase for the current System.Web.HttpContext. Facilitates efficient consolidation of methods that require support for both System.Web.HttpContext/System.Web.HttpContextBase typed params. This method is optimised such that the System.Web.HttpContextBase instance returned is only created once per request. NB: this may involve a per-appdomain lock when reading from the items dictionary.

GetInferredLanguage ( this context ) : LanguageTag

Returns the language for the current request inferred from the request context: that is, attributes of the request other that the URL.

The language is infered from the following attributes of the request, in order of preference:
i18n.langtag cookie
Accept-Language header
fall back to i18n.LocalizedApplication.Current.DefaultLanguage
Additionally, each language is matched by the language matching algorithm against the set of application languages available.

GetPrincipalAppLanguageForRequest ( this context ) : ILanguageTag

Returns any cached per-request value that identifies the Principle Application Language (PAL) with which the current request is to be processed. That is, the value of any most-recent call to SetPrincipalAppLanguageForRequest. If SetPrincipalAppLanguageForRequest has not yet been called for the request, returns the default app language.

GetRequestUserLanguages ( this context ) : LanguageItem[]

Returns a collection of languages supported by the user-agent, in descending order of preference. The first item in the collection refers to any Principle Application Language (PAL) for the request determined by EarlyUrlLocalization (which calls SetPrincipalAppLanguageForRequest), or is null if EarlyUrlLocalization is disabled.

This method is optimised such that the collection is built only once per request.

GetText ( this context, string msgid, string msgcomment, bool allowLookupWithHtmlDecodedMsgId = true ) : string

Returns any translation for the passed individual message.

This this the main entry point into i18n library for translating strings. Selection of acceptable user languages is determined per-request and that is used to resolve the msgid against any existing localized versions of that string. Should no translation exist, the msgid string is returned.

ParseAndTranslate ( this context, string entity ) : string

Returns the translation of the passed string entity which may contain zero or more fully-formed nugget.

SetContentLanguageHeader ( this context ) : bool

Add a Content-Language HTTP header to the response, based on any languages that have provided resources during the request.

SetPrincipalAppLanguageForRequest ( this context, ILanguageTag pal, bool updateThreadCulture = true ) : void

Helper for caching a per-request value that identifies the principal language under which the current request is to be handled.

비공개 메소드들

메소드 설명
HttpContextExtensions ( ) : System

메소드 상세

ChooseAppLanguage() 공개 정적인 메소드

Runs the Language Matching Algorithm for the UserLanguages of the current request against the specified array of AppLanguages, returning the AppLanguage determined to be the best match.
public static ChooseAppLanguage ( this context, IEnumerable AppLanguages ) : LanguageTag
context this Context of the current request.
AppLanguages IEnumerable /// The list of languages in which an arbitrary resource is available. ///
리턴 LanguageTag

GetHttpContextBase() 공개 정적인 메소드

Returns an System.Web.HttpContextBase for the current System.Web.HttpContext. Facilitates efficient consolidation of methods that require support for both System.Web.HttpContext/System.Web.HttpContextBase typed params. This method is optimised such that the System.Web.HttpContextBase instance returned is only created once per request. NB: this may involve a per-appdomain lock when reading from the items dictionary.
public static GetHttpContextBase ( this context ) : System.Web.HttpContextBase
context this
리턴 System.Web.HttpContextBase

GetInferredLanguage() 공개 정적인 메소드

Returns the language for the current request inferred from the request context: that is, attributes of the request other that the URL.
The language is infered from the following attributes of the request, in order of preference:
i18n.langtag cookie
Accept-Language header
fall back to i18n.LocalizedApplication.Current.DefaultLanguage
Additionally, each language is matched by the language matching algorithm against the set of application languages available.
/// Expected GetRequestUserLanguages to fall back to default language. ///
public static GetInferredLanguage ( this context ) : LanguageTag
context this Context of the current request.
리턴 LanguageTag

GetPrincipalAppLanguageForRequest() 공개 정적인 메소드

Returns any cached per-request value that identifies the Principle Application Language (PAL) with which the current request is to be processed. That is, the value of any most-recent call to SetPrincipalAppLanguageForRequest. If SetPrincipalAppLanguageForRequest has not yet been called for the request, returns the default app language.
public static GetPrincipalAppLanguageForRequest ( this context ) : ILanguageTag
context this Context of the request.
리턴 ILanguageTag

GetRequestUserLanguages() 공개 정적인 메소드

Returns a collection of languages supported by the user-agent, in descending order of preference. The first item in the collection refers to any Principle Application Language (PAL) for the request determined by EarlyUrlLocalization (which calls SetPrincipalAppLanguageForRequest), or is null if EarlyUrlLocalization is disabled.
This method is optimised such that the collection is built only once per request.
public static GetRequestUserLanguages ( this context ) : LanguageItem[]
context this Context of the current request.
리턴 LanguageItem[]

GetText() 공개 정적인 메소드

Returns any translation for the passed individual message.
This this the main entry point into i18n library for translating strings. Selection of acceptable user languages is determined per-request and that is used to resolve the msgid against any existing localized versions of that string. Should no translation exist, the msgid string is returned.
public static GetText ( this context, string msgid, string msgcomment, bool allowLookupWithHtmlDecodedMsgId = true ) : string
context this Describes the current request.
msgid string Specifies the individual message to be translated (the first part inside of a nugget). E.g. if the nugget is [[[Sign in]] then this param is "Sign in".
msgcomment string Specifies the optional message comment value of the subject resource, or null/empty.
allowLookupWithHtmlDecodedMsgId bool /// Controls whether a lookup will be attempted with HtmlDecoded-msgid should the first lookup with raw msgid fail. /// Defaults to true. ///
리턴 string

ParseAndTranslate() 공개 정적인 메소드

Returns the translation of the passed string entity which may contain zero or more fully-formed nugget.
public static ParseAndTranslate ( this context, string entity ) : string
context this Describes the current request.
entity string String containing zero or more fully-formed nuggets which are to be translated according to the language selection of the current request.
리턴 string

SetContentLanguageHeader() 공개 정적인 메소드

Add a Content-Language HTTP header to the response, based on any languages that have provided resources during the request.
public static SetContentLanguageHeader ( this context ) : bool
context this Context of the current request.
리턴 bool

SetPrincipalAppLanguageForRequest() 공개 정적인 메소드

Helper for caching a per-request value that identifies the principal language under which the current request is to be handled.
public static SetPrincipalAppLanguageForRequest ( this context, ILanguageTag pal, bool updateThreadCulture = true ) : void
context this Context of the request.
pal ILanguageTag Selected AppLanguage aka Principle Application Language (PAL).
updateThreadCulture bool /// Indicates whether to also update the thread CurrentCulture/CurrentUICulture settings. ///
리턴 void