Class LanguageSelector
Default implementation of language selection on multilingual pages, see static method AutoDetect for default behaviour
Implements
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 8.11.0Syntax
public class LanguageSelector : LoaderOptions, IEnumerable<LoaderOption>, IEnumerable, ILanguageSelector, ILanguageSelectionSource, IXmlSerializable
Remarks
This class is not thread-safe, it should not be cached or stored in static member variables - always create a new instance of this class by for example calling AutoDetect or using the constructor with a language branch.
Constructors
LanguageSelector()
Initializes a new instance of the LanguageSelector class.
Declaration
protected LanguageSelector()
LanguageSelector(String)
Default constructor for a pre-defined language
Declaration
public LanguageSelector(string languageBranch)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | languageBranch | The language branch. |
LanguageSelector(String, IContentLanguageSettingsHandler)
Constructor for a pre-defined language that takes in external dependency
Declaration
public LanguageSelector(string languageBranch, IContentLanguageSettingsHandler languageSettingsHandler)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | languageBranch | The language branch. |
| IContentLanguageSettingsHandler | languageSettingsHandler | The language settings handler. |
Remarks
This is mainly to be used in unit tests. When IContentLanguageSettingsHandler is not specified Instance will be used.
Properties
AutoSelect
Indicates whether the language returned is automatically selected from the pages language configuration.
Declaration
protected bool AutoSelect { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
FallbackToMaster
Indicates whether the returned pages language will fall back to the master language if the requested language doesn't exist.
Declaration
protected bool FallbackToMaster { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Language
Declaration
public CultureInfo Language { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Globalization.CultureInfo |
LanguageBranch
Setting the LanguageBranch to a value is equal to creating the object with the parameterized constructor.
Declaration
public string LanguageBranch { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Remarks
Autodetect and Fallback to master will be set to false
SelectionSource
Gets what selection source was used when selecting the language.
Declaration
public virtual LanguageSelectionSource SelectionSource { get; protected set; }
Property Value
| Type | Description |
|---|---|
| LanguageSelectionSource |
Methods
AddXmlSchema(XmlSchemaSet)
Supports creating a CMS 5 compatible WSDL schema for LanguageSelector via System.Xml.Serialization.XmlSchemaProviderAttribute
Declaration
public static XmlQualifiedName AddXmlSchema(XmlSchemaSet xs)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Xml.Schema.XmlSchemaSet | xs |
Returns
| Type | Description |
|---|---|
| System.Xml.XmlQualifiedName |
AutoDetect()
Creates a language selector that reads current language selection and enables replacement and fallback language handling.
Declaration
public static LanguageSelector AutoDetect()
Returns
| Type | Description |
|---|---|
| LanguageSelector | A language selector object |
Remarks
Using AutoDetect without parameters will result in no master language fallback handling.
AutoDetect(Boolean)
Creates a language selector that reads current language selection and enables fallback languages
Declaration
public static LanguageSelector AutoDetect(bool enableMasterLanguageFallback)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | enableMasterLanguageFallback | Enable master language as a last resort for fallback instead of filtering a page |
Returns
| Type | Description |
|---|---|
| LanguageSelector | A language selector object |
Fallback(String, Boolean)
Creates a language selector with a custom language selection and enables fallback languages
Declaration
public static LanguageSelector Fallback(string preferredLanguageBranch, bool enableMasterLanguageFallback)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | preferredLanguageBranch | The prefered language branch (overrides user choice) |
| System.Boolean | enableMasterLanguageFallback | Enable master language as a last resort for fallback instead of filtering a page |
Returns
| Type | Description |
|---|---|
| LanguageSelector | A language selector object |
LoadLanguage(LanguageSelectorContext)
Selects language branch based on a page link only, used for example when creating new pages
Declaration
[Obsolete("Simplify code in content providers to only use the Language property to get requested language (ILanguageSelector.Language). Removed usage of LanguageSelectorContext since fallback languages are now handled outside the provider.")]
public virtual void LoadLanguage(LanguageSelectorContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| LanguageSelectorContext | context | The context which the method executes in |
MasterLanguage()
Creates a language selector that always selects the master language of a page
Declaration
public static LanguageSelector MasterLanguage()
Returns
| Type | Description |
|---|---|
| LanguageSelector | A language selector object |
SelectPageLanguage(LanguageSelectorContext)
Selects which language branch of a page that should be loaded, used for examples in listings
Declaration
[Obsolete("Simplify code in content providers to only use the Language property to get requested language (ILanguageSelector.Language). Removed usage of LanguageSelectorContext since fallback languages are now handled outside the provider.")]
public virtual void SelectPageLanguage(LanguageSelectorContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| LanguageSelectorContext | context | The context for which the method is called |
SetInitializedLanguageBranch(LanguageSelectorContext)
Sets SelectedLanguage property with language branch that selector was initialized with, if any.
Declaration
[Obsolete("Simplify code in content providers to only use the Language property to get requested language (ILanguageSelector.Language). Removed usage of LanguageSelectorContext since fallback languages are now handled outside the provider.")]
public virtual void SetInitializedLanguageBranch(LanguageSelectorContext args)
Parameters
| Type | Name | Description |
|---|---|---|
| LanguageSelectorContext | args | the context to operate on |