using CMS.CMSHelper;
using CMS.GlobalHelper;
using CMS.PortalControls;
using CMS.PortalEngine;
public partial class CMSWebParts_Localization_GoogleTranslator : CMSAbstractWebPart
{
#region "Page events"
///
/// Loads the web part content.
///
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
#endregion
#region "Other methods"
///
/// Sets up the control.
///
protected void SetupControl()
{
if (StopProcessing)
{
// Do nothing
}
else
{
if ((CMSContext.ViewMode == ViewModeEnum.LiveSite) || (CMSContext.ViewMode == ViewModeEnum.Preview))
{
string culture = CultureHelper.GetShortCultureCode(CMSContext.CurrentDocumentCulture.CultureCode);
// Registers Google Translator scripts
string translateScript = "function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: '" + culture + "'}, 'google_translate_element');}";
ScriptHelper.RegisterClientScriptBlock(Page, Page.GetType(), "GoogleTranslatorScript", translateScript, true);
ScriptHelper.RegisterScriptFile(Page, "http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit");
}
}
}
#endregion
}