November Happy Hour will be moved to Thursday December 5th.

Class ContentLanguage

Implementation of the LanguageSelection class.

Inheritance
System.Object
ContentLanguage
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Globalization
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
public class ContentLanguage : LanguageSelection

Constructors

ContentLanguage()

Initializes a new instance of the ContentLanguage class.

Declaration
public ContentLanguage()

ContentLanguage(ILanguageBranchRepository)

Initializes a new instance of the ContentLanguage class.

Declaration
public ContentLanguage(ILanguageBranchRepository languageBranchRepository)
Parameters
Type Name Description
ILanguageBranchRepository languageBranchRepository

The language branch repository used by this instance.

ContentLanguage(ILanguageBranchRepository, HostLanguageResolver, ServiceAccessor<HttpRequestBase>)

Initializes a new instance of the ContentLanguage class.

Declaration
public ContentLanguage(ILanguageBranchRepository languageBranchRepository, HostLanguageResolver hostLanguageResolver, ServiceAccessor<HttpRequestBase> currentHttpRequest)
Parameters
Type Name Description
ILanguageBranchRepository languageBranchRepository

The language branch repository used by this instance.

HostLanguageResolver hostLanguageResolver

The host language resolver used by this instance.

ServiceAccessor<System.Web.HttpRequestBase> currentHttpRequest

An accessor to the current HTTP request instance.

Properties

FinalFallbackCulture

Gets the final fallback culture.

Declaration
public override CultureInfo FinalFallbackCulture { get; }
Property Value
Type Description
System.Globalization.CultureInfo

The final fallback culture.

Overrides
Remarks

When all other culture/language resolution mechanisms fail, this is the final resort to get a valid culture for ContentLanguage.

Instance

Gets or sets the instance of Contentlanguage to use.

Declaration
public static ContentLanguage Instance { get; set; }
Property Value
Type Description
ContentLanguage

The instance.

Remarks

Assigning to this property allows you to completely replace how the preferred content language is determined by implementing the DeterminePreferredLanguage method.

PreferredCulture

Gets or sets the preferred content culture.

Declaration
public static CultureInfo PreferredCulture { get; set; }
Property Value
Type Description
System.Globalization.CultureInfo

The current culture.

Remarks

To access the language code which is used to look up information in LocalizationService and/or LanguageBranch, simply read the Name property of the returned CultureInfo object.

SpecificCulture

Gets the specific culture.

Declaration
public static CultureInfo SpecificCulture { get; }
Property Value
Type Description
System.Globalization.CultureInfo

The specific culture.

Remarks

If the PreferredCulture is a neutral culture and you need to get sort order and/or formatting information you should call this property to get the specific culture that is associated with the neutral culture. Note that if the PreferredCulture is already a specific culture, no extra object will be created.

Methods

DetermineCulture(LanguagePreferenceList)

Determines the preferred content language for the current request.

Declaration
public override CultureInfo DetermineCulture(LanguagePreferenceList preferenceList)
Parameters
Type Name Description
LanguagePreferenceList preferenceList
Returns
Type Description
System.Globalization.CultureInfo

A string with the language code for the CultureInfo set as PreferredCulture.

Overrides

IsValid(CultureInfo)

Validates culture

Declaration
public bool IsValid(CultureInfo culture)
Parameters
Type Name Description
System.Globalization.CultureInfo culture

System.Globalization.CultureInfo object.

Returns
Type Description
System.Boolean

boolean

IsValid(String)

Validates culture

Declaration
public bool IsValid(string languageCode)
Parameters
Type Name Description
System.String languageCode

Culture name

Returns
Type Description
System.Boolean

boolean

LanguagePreferenceList(String)

Get all preferred languages a list of language codes.

Declaration
public override LanguagePreferenceList LanguagePreferenceList(string priorityLanguage)
Parameters
Type Name Description
System.String priorityLanguage
Returns
Type Description
LanguagePreferenceList

An IList<string> with language codes in priority order.

Overrides

ResetPreferredCultureIfAuthenticatedRequest(Object, EventArgs)

Handler that resets preferred culture for authenticated user

Declaration
public static void ResetPreferredCultureIfAuthenticatedRequest(object sender, EventArgs e)
Parameters
Type Name Description
System.Object sender
System.EventArgs e
Remarks

Reset the culture in case it depends on personalized information so it will be recreated upon next access.

SetCulture(String)

Sets preferred culture based on priority language

Declaration
public override CultureInfo SetCulture(string priorityLanguage)
Parameters
Type Name Description
System.String priorityLanguage
Returns
Type Description
System.Globalization.CultureInfo

System.Globalization.CultureInfo object.

Overrides

Extension Methods