Method | Description | |
---|---|---|
ChooseAppLanguage ( this context, IEnumerable |
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: |
|
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.
|
Method | Description | |
---|---|---|
HttpContextExtensions ( ) : System |
public static ChooseAppLanguage ( this context, IEnumerable |
||
context | this | Context of the current request. |
AppLanguages | IEnumerable |
/// The list of languages in which an arbitrary resource is available. /// |
return | LanguageTag |
public static GetHttpContextBase ( this context ) : System.Web.HttpContextBase | ||
context | this | |
return | System.Web.HttpContextBase |
public static GetInferredLanguage ( this context ) : LanguageTag | ||
context | this | Context of the current request. |
return | LanguageTag |
public static GetPrincipalAppLanguageForRequest ( this context ) : ILanguageTag | ||
context | this | Context of the request. |
return | ILanguageTag |
public static GetRequestUserLanguages ( this context ) : LanguageItem[] | ||
context | this | Context of the current request. |
return | LanguageItem[] |
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. /// |
return | string |
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. |
return | string |
public static SetContentLanguageHeader ( this context ) : bool | ||
context | this | Context of the current request. |
return | bool |
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. /// |
return | void |