LanguageAPI
The LanguageAPI server control lets a developer force a particular language for a website. You can do this by dropping the server control on the page and setting a language in the SiteLanguage
property box. You can also override site language logic by programmatically using the LanguageAPI server control to detect the browser’s language, and display the site in that language.
Inserting the LanguageAPI server control onto a page
Prerequisite
You must have installed the server controls. See Installing server controls into Visual Studio Toolbox.
- In Visual Studio, choose View > Toolbox.
- Click the Ektron server control tab to display the server controls.
- Drag the LanguageAPI server control and drop it into the desired location on the page.
NOTE: You also can place the cursor on the page where you want the server control, then double click the server control that you want.
<CMS:LanguageAPI ID="LanguageAPI1" runat="server" />
- Click on
LanguageAPI
in the code to display and modify the control’s properties using the Properties window of Visual Studio. The page is updated as you modify the property values.
LanguageAPI properties
The following are Ektron-specific server controla server control uses API language to interact with the CMS and Framework UI to display the output. A server control can be dragged and dropped onto a Web form and then modified. properties. For information about native .NET properties such as font, height, width and border style, use Visual Studio® help.
- SiteLanguage (String)
Sets the site language. Runs through the IsValid function to verify that the language is an active language in the system.
- SiteLanguageID (Integer)
Numeric value of the site language. This is the property you will use if you are using code-behind to set the sites language ID.
Example: 1036 = French
For a list of supported languages, go to Workarea > Settings > Configuration > Language Settings.
LanguageAPI code-behind Only properties and Methods
The following is a list can only be used programmatically.
- CurrentLanguage (String)
Read only. Returns the current language.
- CurrentLanguageID (Integer)
Read only. Returns the current language ID.
- DefaultLanguage (String)
Read only. What the default language of the site is set to. For example, the demo site is “English (Standard)”.
- DefaultLanguageID (Integer)
Read only. Returns the value that is the default language ID of the site. For example, the demo site is “1033” for English.
- GetLanguage (Integer Argument)
This method returns a string. Pass in a valid language ID and it will return the language name.
- GetLanguageID (Sting Argument)
This method returns an integer. Pass in a valid language name and it will return the language ID.
- IsValid (Argument)
This method returns a boolean. You can pass in a language ID or a string and it will tell you if the system is supporting it.
- LanguageIdList (Array of Integers)
Read only. Lists all the language IDs that are activated in Ektron. For information on how to enable languages, see Determining Which Languages are Available.
- LanguageTitleList (Array of Strings)
Read only. Lists all the languages that are activated in Ektron.
- MultiLanguageEnabled (Boolean)
Read only. Tells if the site supports multi-language mode.
- True (default). Multi-language enabled
- False. Multi-language not enabled
Using LanguageAPI programmatically
This example uses a logo that is not managed through Ektron. It retrieves the current language from the LanguageAPI control, and uses that information to choose the logo version to display. The code-behind looks like this.
Select Case LanguageAPI1.CurrentLanguageID Case 1031 Image1.ImageUrl = "germanlogo.png" Case 1033 Image1.ImageUrl = "englishlogo.png" Case 1036 Image1.ImageUrl = "frenchlogo.png" End Select