Class Translate
WebControl for retrieving language specific strings.
Inheritance
Namespace: EPiServer.Web.WebControls
Assembly: EPiServer.Web.WebControls.dll
Version: 9.12.2Syntax
public class Translate : WebControl
Remarks
Use the Translate control to translate your own strings or one of the built in strings in the /lang directory of you site. The text shown will vary by the current users chosen language (if chosen) or the system default.
The control uses the LocalizationService to translate the text. You can access the LocalizationService through code using the Current static property.
Examples
Using the Translate Control
This will show the translated value for the /button/search language resource.
<episerver:translate text="/button/search" runat="server"/>
Translating ASP Intrinsic controls
EPiServer can also translate ASP Controls like the Label web control. In the PreRender event EPiServer will search all known controls in the control hierarchy with an attribute called translate (case insensitive) and retrieve the translated textual value of the control.
<asp:button id="QuicksearchButton" runat="server" translate="/button/search" />
note
Note: If you do not want automatic retrieval of translated values you can turn this off by setting the TranslateType property in the code behind of your template to None. See PageBase where this property is defined.
Constructors
Translate()
Declaration
public Translate()
Translate(String)
Declaration
public Translate(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text |
Properties
Language
Gets or sets the language code for the target language.
Declaration
public string Language { get; set; }
Property Value
Type | Description |
---|---|
System.String | The language code. |
LocalizedText
Declaration
public string LocalizedText { get; set; }
Property Value
Type | Description |
---|---|
System.String |
StringFormatObjects
Declaration
public object[] StringFormatObjects { get; set; }
Property Value
Type | Description |
---|---|
System.Object[] |
Text
The property that holds the text to be translated.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
See GetStringByCulture(String, CultureInfo) for more details.
Methods
Render(HtmlTextWriter)
Render this control to the output parameter specified.
Declaration
protected override void Render(HtmlTextWriter output)
Parameters
Type | Name | Description |
---|---|---|
System.Web.UI.HtmlTextWriter | output | The HTML writer to write out to |