Class LanguageSelection

The abstract base class for the various language selection features in EPiserver

Inheritance
System.Object
LanguageSelection
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 abstract class LanguageSelection

Constructors

LanguageSelection()

Declaration
protected LanguageSelection()

Properties

FinalFallbackCulture

Gets the final fallback culture.

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

The final fallback culture.

Remarks

This property is used as a final way out when the DetermineCulture method has failed to find a valid culture.

HostLanguageMappings

Gets the host language mappings.

Declaration
public static StringDictionary HostLanguageMappings { get; }
Property Value
Type Description
System.Collections.Specialized.StringDictionary

The host language mappings.

Remarks

This property is used to map a host name, such as www.company.com, to a specific language.

Methods

DetermineCulture(LanguagePreferenceList)

Determines the culture based on the language preferences.

Declaration
public abstract CultureInfo DetermineCulture(LanguagePreferenceList languagePreference)
Parameters
Type Name Description
LanguagePreferenceList languagePreference

The language preferences.

Returns
Type Description
System.Globalization.CultureInfo

A CultureInfo object representing the selected language.

GetDefaultHostLanguage()

Gets the default host language.

Declaration
public static string GetDefaultHostLanguage()
Returns
Type Description
System.String

A string that is a culture name. If no language defined for default host (name="*"), returns null.

Remarks

This code performs its work based on the information in the <siteHostsMappings> section in EPiServerFramework.config.

GetLanguageFromHost()

Gets the language to use based on the host name.

Declaration
public static string GetLanguageFromHost()
Returns
Type Description
System.String

A string that is a culture name. If no match found, returns null.

Remarks

This code performs its work based on the information in the <siteHostsMappings> section in EPiServerFramework.config.

IsCandidateMatch(String, String)

Determines whether there is a potential language match between the language codes.

Declaration
public static bool IsCandidateMatch(string languageCode1, string languageCode2)
Parameters
Type Name Description
System.String languageCode1

The first language code.

System.String languageCode2

The second language code.

Returns
Type Description
System.Boolean

true if it is a candidate match between the strings; otherwise, false.

IsHostLanguageMatch(String)

Determines whether the requested language matches the default language as defined by a hostname-to-language mapping.

Declaration
public static bool IsHostLanguageMatch(string requestedLanguage)
Parameters
Type Name Description
System.String requestedLanguage

The requested language.

Returns
Type Description
System.Boolean

true if the languages math; otherwise, false.

Remarks

The hostname to language mapping is defined in the configuration file (by default EPiServerFramework.config, <siteHostsMapping> section). The purpose of this is that the language indicator segment in the URL is not needed when you have a match between the requested language and the default language as indicated by the host name.

LanguagePreferenceList(String)

Get a list of language codes.

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

The priority language.

Returns
Type Description
LanguagePreferenceList

A LanguagePreferenceList sorted in preference order.

SetCulture()

Sets the culture for the specific language type.

Declaration
public CultureInfo SetCulture()
Returns
Type Description
System.Globalization.CultureInfo

SetCulture(String)

Sets the culture for the specific language type.

Declaration
public abstract CultureInfo SetCulture(string priorityLanguage)
Parameters
Type Name Description
System.String priorityLanguage

The priority language.

Returns
Type Description
System.Globalization.CultureInfo

The CultureInfo object that has been stored for tyis language type.

Remarks

The priorityLanguage parameter is available to help implementing simple overrides of the language selection mechanism by putting the priority language first in the language preference list.

TryGetCulture(String, out CultureInfo)

Tries to retrieve a culture from a language code.

Declaration
public static bool TryGetCulture(string languageCode, out CultureInfo culture)
Parameters
Type Name Description
System.String languageCode

The language code.

System.Globalization.CultureInfo culture

The culture.

Returns
Type Description
System.Boolean

true if culture contains a valid culture; false if the process failed.

Extension Methods