Class HostLanguageResolver
Handles mappings from host to language.
Inheritance
Inherited Members
Namespace: EPiServer.Globalization
Assembly: EPiServer.dll
Version: 7.19.2Syntax
public class HostLanguageResolver
Constructors
HostLanguageResolver(SiteDefinitionRepository, SiteDefinitionResolver)
Initializes a new instance of the HostLanguageResolver class.
Declaration
public HostLanguageResolver(SiteDefinitionRepository siteDefinitionRepository, SiteDefinitionResolver siteDefinitionResolver)
Parameters
Type | Name | Description |
---|---|---|
SiteDefinitionRepository | siteDefinitionRepository | The site definition repository. |
SiteDefinitionResolver | siteDefinitionResolver | The site definition resolver. |
Properties
HostLanguageMappings
Gets the host language mappings.
Declaration
public virtual 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
GetDefaultHostLanguage()
Gets the default host language.
Declaration
public virtual 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.
GetHostForLanguage(String, String)
Gets the host for specified language given site specified by siteUrl
.
Declaration
public virtual string GetHostForLanguage(string language, string siteUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | The language. |
System.String | siteUrl | The site URL. |
Returns
Type | Description |
---|---|
System.String |
GetHostsForLanguage(String, String)
Gets the hosts that is mapped for specified language given site specified by siteUrl
.
Declaration
public virtual IEnumerable<string> GetHostsForLanguage(string language, string siteUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | The language. |
System.String | siteUrl | The site URL. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
GetLanguageForHost(String, Boolean)
Gets the language mapping defined for a host.
Declaration
public virtual string GetLanguageForHost(string hostName, bool fallback)
Parameters
Type | Name | Description |
---|---|---|
System.String | hostName | Name of the host. |
System.Boolean | fallback | if set to |
Returns
Type | Description |
---|---|
System.String |
GetLanguageFromRequest(HttpRequestBase)
Gets the language to use based on the host name.
Declaration
public virtual string GetLanguageFromRequest(HttpRequestBase request)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpRequestBase | request |
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.
IsHostLanguageMatch(HttpRequestBase, String)
Determines whether the requested language matches the default language as defined by a hostname-to-language mapping.
Declaration
public virtual bool IsHostLanguageMatch(HttpRequestBase request, string requestedLanguage)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpRequestBase | request | The request. |
System.String | requestedLanguage | The requested language. |
Returns
Type | Description |
---|---|
System.Boolean |
|
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.