Class PageTranslation
PageExtension that handles translation for localized controls on a Page inherited from PageBase
Inheritance
Inherited Members
Namespace: EPiServer.Web.PageExtensions
Assembly: EPiServer.dll
Version: 8.11.0Syntax
[PagePlugIn("Control translation", "Function to facilitate use of localized controls.")]
public class PageTranslation
Constructors
PageTranslation()
Initializes a new instance of the PageTranslation class.
Declaration
public PageTranslation()
Properties
LocalizationService
Gets or sets the localization service.
Declaration
public LocalizationService LocalizationService { get; set; }
Property Value
Type | Description |
---|---|
LocalizationService | The localization service. |
OptionFlag
Flag value to determine if this plug in should be enabled.
Declaration
public static int OptionFlag { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Page
Gets the page which localized controls will be translated
Declaration
public PageBase Page { get; }
Property Value
Type | Description |
---|---|
PageBase | The page. |
TranslateType
Select the type of automatic translation of controls that will take place.
Declaration
public TranslateType TranslateType { get; set; }
Property Value
Type | Description |
---|---|
TranslateType |
Remarks
If you know that there are no controls that contains text to be translated, set TranslateType to None to improve performance.
Methods
Attach(Page)
Attaches the specified content base web form.
Declaration
public void Attach(Page page)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Page | page | The content base web form. |
Initialize(Int32)
Method called at system startup to initialize this plug in.
Declaration
public static void Initialize(int optionFlag)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | optionFlag | The option flag value assigned to this plug in. |
Remarks
Using the plugin attribute [PagePlugIn] requires the class to contain a static void method named "Initialize" which will be called to attach to suitable event handlers.
TranslateExplicitControl(ITranslate)
Called to translate a control implementing ITranslate. The implementation will check to see if control implements ITranslateFormat and if so use LocalizedText and StringFormatObjects to do the translation. Else if control not implements ITranslateFormat the translation will be performed using LocalizedText
Declaration
protected void TranslateExplicitControl(ITranslate translate)
Parameters
Type | Name | Description |
---|---|---|
ITranslate | translate | The translate. |
TranslateHtmlControl(HtmlControl)
Translates System.Web.UI.HtmlControls.HtmlControl that has translate attribute. Supported controls are System.Web.UI.HtmlControls.HtmlInputButton, System.Web.UI.HtmlControls.HtmlTableCell and System.Web.UI.HtmlControls.HtmlImage
Declaration
protected void TranslateHtmlControl(HtmlControl htmlControl)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.HtmlControls.HtmlControl | htmlControl | The HTML control. |
TranslatePageControls()
Translates all controls on the page.
Declaration
public void TranslatePageControls()
TranslateSingleControl(Control)
Called to translate UI text for controls
Declaration
public virtual bool TranslateSingleControl(Control control)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.Control | control | The control to translate |
Returns
Type | Description |
---|---|
System.Boolean | True if the control was of a type that can be translated |
Remarks
This method can be overridden to support custom controls that needs translation support. It currently supports
- EPiServer.Core.ITranslateLocalizedText property
- System.Web.UI.HtmlControls.HtmlInputButtonValue property
- System.Web.UI.HtmlControls.HtmlTableCellInnerText property
- System.Web.UI.WebControls.ButtonText property
- System.Web.UI.WebControls.HyperLinkText property
- System.Web.UI.WebControls.LabelText property
- System.Web.UI.WebControls.LinkButtonText property
The method currently dont support System.Web.UI.WebControls.Literal since literal control inherits from control class directly not from webcontrol. This makes it not possible to manipulate attributes on Literal control. Instead use Resources or a Label control for translation.
For all controls that do not support the ITranslate interface, the translation mechanism uses the attribute "translate" to collect the translatable string. It will then set the indicated property of the control to the translated string.
TranslateWebControl(WebControl)
Translates System.Web.UI.WebControls.WebControl that has translate attribute. Supported controls are System.Web.UI.WebControls.Label, System.Web.UI.WebControls.Button , System.Web.UI.WebControls.HyperLink and System.Web.UI.WebControls.LinkButton
Declaration
protected void TranslateWebControl(WebControl webControl)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.WebControls.WebControl | webControl | The web control. |