Class LanguageBranch
Administrative interface to language branches used for multilanguage pages.
Inheritance
Inherited Members
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 8.11.0Syntax
public class LanguageBranch
Constructors
LanguageBranch()
Initializes a new instance of the LanguageBranch class.
Declaration
public LanguageBranch()
LanguageBranch(CultureInfo)
Initializes a new instance of the LanguageBranch class.
Declaration
public LanguageBranch(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The culture. |
LanguageBranch(Int32, String, String, Int32, String, String, Boolean)
Initializes a new instance of the LanguageBranch class.
Declaration
public LanguageBranch(int id, string languageID, string name, int sortIndex, string rawIconPath, string urlSegment, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The internal numeric ID. |
System.String | languageID | The language ID. |
System.String | name | The name of the language. |
System.Int32 | sortIndex | Index to sort on. |
System.String | rawIconPath | The raw icon path. |
System.String | urlSegment | The URL segment that identifies the language when used in a URL. |
System.Boolean | enabled | if set to |
LanguageBranch(String, String)
Initializes a new instance of the LanguageBranch class.
Declaration
public LanguageBranch(string languageID, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | languageID | The language ID. |
System.String | name | The name of the language. |
Fields
CacheKey
String used as cache key for language branches.
Declaration
public const string CacheKey = "EP:LanguageBranch"
Field Value
Type | Description |
---|---|
System.String |
Properties
ACL
Gets or sets the ACL for this language.
Declaration
public AccessControlList ACL { get; set; }
Property Value
Type | Description |
---|---|
AccessControlList | The AccessControlList for this language. |
Culture
Gets the culture for this language.
Declaration
public CultureInfo Culture { get; }
Property Value
Type | Description |
---|---|
System.Globalization.CultureInfo | The culture. |
CurrentUrlSegment
Gets the current URL segment string to use when creating or verifying Friendly URL:s
Declaration
public string CurrentUrlSegment { get; }
Property Value
Type | Description |
---|---|
System.String | The current URL segment. |
Remarks
The difference between this property and URLSegment is that CurrentUrlSegment will fallback to LanguageID if URLSegment is undefined, i e you can directly use this property in code working with URL segments.
Enabled
If language is enabled
Declaration
public bool Enabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ID
The language branch unique identifier
Declaration
public int ID { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
LanguageBranchRepository
Convenient method to get the instance of ILanguageBranchRepository that is registered in ServiceLocator.
Declaration
public static ILanguageBranchRepository LanguageBranchRepository { get; }
Property Value
Type | Description |
---|---|
ILanguageBranchRepository | The language branch repository. |
LanguageID
Actual language name, for example "en"
Declaration
public string LanguageID { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Note that this is the Name property of a CultureInfo object.
Name
The display name of this language.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
Unless explicitly set, this property returns the NativeName property of a CultureInfo object.
RawIconPath
Gets or sets the raw icon path.
Declaration
public string RawIconPath { get; }
Property Value
Type | Description |
---|---|
System.String | The flag icon path. |
ResolvedIconPath
Gets the icon path.
Declaration
public string ResolvedIconPath { get; }
Property Value
Type | Description |
---|---|
System.String | The resolved icon path. |
Remarks
Use this property to get path to Flag outside admin/edit. Uses UriSupport.ResolveUrlBySettings to resolve path to flag.
SortIndex
Sort index used for listings etc
Declaration
public int SortIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
SystemIconPath
Path to icon used for admin and edit.
Declaration
public string SystemIconPath { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
This property is not to be used outside admin/edit. Uses ThemeUtility.GetImageThemeUrl to get Icon path.
URLSegment
Custom language name used in URL segments.
Declaration
public string URLSegment { get; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
The difference between this property and CurrentUrlSegment is that URLSegment only represents the editable, alternate, name for the URL segment. If URLSegment holds a valid value, then it should be used for creating and parsing friendly URLs.
Methods
Delete()
Delete the current branch
Declaration
[Obsolete("Use ILanguageBranchRepository.Delete(LanguageBranch branch) instead")]
public void Delete()
Remarks
Always do try catch when trying to delete branch.
ListAll()
Lists all language branches.
Declaration
[Obsolete("Use ILanguageBranchRepository.ListAll() instead")]
public static LanguageBranchCollection ListAll()
Returns
Type | Description |
---|---|
LanguageBranchCollection | A LanguageBranchCollection with all language branches. |
ListEnabled()
Lists only the enabled language branches.
Declaration
[Obsolete("Use ILanguageBranchRepository.ListEnabled() instead")]
public static LanguageBranchCollection ListEnabled()
Returns
Type | Description |
---|---|
LanguageBranchCollection | A LanguageBranchCollection with enabled language branches. |
Load(CultureInfo)
Loads the language definition based on the specified culture.
Declaration
[Obsolete("Use ILanguageBranchRepository.Load(CultureInfo culture) instead")]
public static LanguageBranch Load(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | The culture. |
Returns
Type | Description |
---|---|
LanguageBranch | A LanguageBranch instance or null if language not found. |
Load(Int32)
Load the language definition with the given language id
Declaration
[Obsolete("Use ILanguageBranchRepository.Load(int id) instead")]
public static LanguageBranch Load(int id)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | id | The id. |
Returns
Type | Description |
---|---|
LanguageBranch | The language branch or null if no branch is found |
Load(String)
Load the language definition with the given language key
Declaration
[Obsolete("Use ILanguageBranchRepository.Load(CultureInfo culture) instead")]
public static LanguageBranch Load(string languageCode)
Parameters
Type | Name | Description |
---|---|---|
System.String | languageCode | The language code. |
Returns
Type | Description |
---|---|
LanguageBranch | The language branch or null if no branch is found |
LoadFirstEnabledBranch()
Load the first enabled language branch.
Declaration
[Obsolete("Use ILanguageBranchRepository.LoadFirstEnabledBranch() instead")]
public static LanguageBranch LoadFirstEnabledBranch()
Returns
Type | Description |
---|---|
LanguageBranch |
Remarks
Throws an exception if no language branches are enabled.
QueryEditAccessRights(IPrincipal)
Queries if the user has edit access rights to the language branch.
Declaration
public bool QueryEditAccessRights(IPrincipal user)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Principal.IPrincipal | user | The user. |
Returns
Type | Description |
---|---|
System.Boolean | True if the user has edit access to the language; otherwise false. |
Save()
Saves language information or creates a new language
Declaration
[Obsolete("Use ILanguageBranchRepository.Save() instead")]
public void Save()
Remarks
Always do try catch when trying to save branch.
ValidateLanguageEdititingAccessRights(IPrincipal)
Validates that the user has access rights to edit the page in the given language.
Declaration
public void ValidateLanguageEdititingAccessRights(IPrincipal user)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Principal.IPrincipal | user | The user. |