protected bool Util_HasInvalidDependency() { bool hasDependency = false; long[] targetJobs = (new List<long>() { m_iID }).ToArray(); Ektron.Cms.BusinessObjects.Localization.L10nManager businessMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef); string title = "Content Not Ready for Translation"; LocalizationExportJob exportJob = new LocalizationExportJob(title); exportJob.SourceLanguageId = 1033; exportJob.Items = new List<LocalizableItem>(); exportJob.Items.Add(new LocalizableItem(LocalizableCmsObjectType.LocaleTaxonomy, m_iID)); exportJob.XliffVersion = this.xliffVersion; Criteria<LocalizationExportJob> criteria = new Criteria<LocalizationExportJob>(); criteria.PagingInfo.RecordsPerPage = 50; List<Ektron.Cms.BusinessObjects.Localization.ILocalizable> items = businessMgr.GetNotReadyList(exportJob, criteria); if (items.Count > 0) { hasDependency = true; Util_ShowError("Dependencies are not ready for localization."); ltr_JobStatus.Text = "Warning"; rptNotReadyContent.Visible = true; rptNotReadyContent.DataSource = items; rptNotReadyContent.DataBind(); } invalidDependency = hasDependency; return hasDependency; }
protected bool Util_HasTargetLocales() { bool hasTargetLocales = true; long[] targetJobs = (new List<long>() { m_iID }).ToArray(); Ektron.Cms.BusinessObjects.Localization.L10nManager businessMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef); string title = "Content with no Target Locale"; LocalizationExportJob exportJob = new LocalizationExportJob(title); exportJob.SourceLanguageId = 1033; exportJob.Items = new List<LocalizableItem>(); exportJob.Items.Add(new LocalizableItem(LocalizableCmsObjectType.LocaleTaxonomy, m_iID)); exportJob.XliffVersion = this.xliffVersion; Criteria<LocalizationExportJob> criteria = new Criteria<LocalizationExportJob>(); criteria.PagingInfo.RecordsPerPage = 5; List<LocalizableItem> fullList = businessMgr.GetLocaleTaxonomyContents(exportJob); if (fullList.Count > 0) { LocalizableItem item = fullList.ElementAt(0); List<LocalizationObjectData> localeObjectData = new List<LocalizationObjectData>(); Ektron.Cms.Framework.Localization.LocalizationObject localizationObject = new Ektron.Cms.Framework.Localization.LocalizationObject(); localeObjectData = localizationObject.GetLocalizationObjectList(LocalizableCmsObjectType.Content, item.Id, -1); if (0 == localeObjectData.Count) { localeObjectData = localizationObject.GetLocalizationObjectList(LocalizableCmsObjectType.DmsAsset, item.Id, -1); } if (0 == localeObjectData.Count) { hasTargetLocales = false; Util_ShowError("No Content found."); ltr_JobStatus.Text = "Error"; } else if (1 == localeObjectData.Count) { hasTargetLocales = false; Util_ShowError(this.GetMessage("lbl target languages are not set for this handoff package")); ltr_JobStatus.Text = "Error"; } } return hasTargetLocales; }
protected long Process_PseudoLocalize() { //Ektron.Cms.Framework.Localization.LocaleManager locale = new Ektron.Cms.Framework.Localization.LocaleManager(); //List<Ektron.Cms.Localization.LocaleData> pseudoLocales = locale.GetEnabledLocales().FindAll(d => d.XmlLang.Contains("-x-pseudo")); //this.languageIds = pseudoLocales.ConvertAll<int>(delegate(Ektron.Cms.Localization.LocaleData l) { return l.Id; }); if (0 == this.languageIds.Count) { return 0; } //if (this.localeMgr.FindLocale(pseudoLocales, contentData.LanguageId) != null) //{ // return; //} LocalizableCmsObjectType locType = LocalizableCmsObjectType.Content; LocalizationExportJob job = new LocalizationExportJob(pseudoLocJobTitle); job.SourceLanguageId = 1033; job.XliffVersion = this.xliffVersion; foreach (long contentId in contentIds) { long contentType = this.m_refContentApi.EkContentRef.GetContentType(contentId); if (Ektron.Cms.Common.EkConstants.IsAssetContentType(contentType, true)) locType = LocalizableCmsObjectType.DmsAsset; job.AddItem(locType, contentId, this.languageIds); } job.TargetLanguageIds = this.languageIds; job.PseudoLocalize = true; // allows content "NotReady" to be exported Ektron.Cms.BusinessObjects.Localization.L10nManager businessMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef); return businessMgr.StartExportForTranslation(job); }
protected long Process_TranslationMemory() { if (0 == this.languageIds.Count) { return 0; } Ektron.Cms.Framework.Localization.LocalizationObject lobjApi = new Ektron.Cms.Framework.Localization.LocalizationObject(); LocalizableCmsObjectType locType = LocalizableCmsObjectType.Content; LocalizationExportJob job = new LocalizationExportJob(transMemJobTitle); job.SourceLanguageId = this.languageIds[0]; job.XliffVersion = this.xliffVersion; foreach (long contentId in contentIds) { long contentType = this.m_refContentApi.EkContentRef.GetContentType(contentId); if (Ektron.Cms.Common.EkConstants.IsAssetContentType(contentType, true)) locType = LocalizableCmsObjectType.DmsAsset; job.AddItem(locType, contentId, this.languageIds); if (this.languageIds[0] != null) lobjApi.MarkNeedsTranslation(locType, contentId, this.languageIds[0]); } job.TargetLanguageIds = this.languageIds; Ektron.Cms.BusinessObjects.Localization.L10nManager businessMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef); return businessMgr.StartExportForTranslation(job); }
public localization_uc() { Load += Page_Load; Init += Page_Init; localizationManager = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.m_refContentApi.RequestInformationRef); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Response.CacheControl = "no-cache"; Response.AddHeader("Pragma", "no-cache"); Response.Expires = -1; ltrConfirmDelMsg.Text = GetMessage("js: confirm delete localization history"); tvJobs.CollapseImageToolTip = GetMessage("lbl collapse"); tvJobs.ExpandImageToolTip = GetMessage("lbl expand"); tvJobs.Load += this.tvJobs_Load; tvJobs.SelectedNodeChanged += this.tvJobs_SelectedNodeChanged; tvJobs.TreeNodePopulate += this.tvJobs_TreeNodePopulate; if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(GetCommonApi().RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.Xliff, false)) { Utilities.ShowError(GetMessage("feature locked error")); } else { string strCancelJobID = Request.QueryString["cancel"]; long cancelJobId = 0; if (long.TryParse(strCancelJobID, out cancelJobId)) { this.localizationApi.CancelJob(cancelJobId); } Ektron.Cms.BusinessObjects.Localization.L10nManager l10nMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(GetCommonApi().RequestInformationRef); string strDeleteJobID = Request.QueryString["delete"]; long deleteJobId = 0; if (long.TryParse(strDeleteJobID, out deleteJobId)) { l10nMgr.DeleteJob(deleteJobId); } string strDeleteAllBeforeJobID = Request.QueryString["deleteall"]; long deleteAllBeforeJobId = 0; if (long.TryParse(strDeleteAllBeforeJobID, out deleteAllBeforeJobId)) { l10nMgr.DeleteJobAndOlder(deleteAllBeforeJobId); } } }
/// <summary> /// Method called when job is started /// </summary> private void ExportForTranslation() { string xliffVersion = txtXliffVer.SelectedValue; if (xliffVersion == this.requestInfoRef.XliffVersion) { this.commonApi.SetCookieValue("xliff", string.Empty); } else { this.commonApi.SetCookieValue("xliff", xliffVersion); } string maxZipFileSize = lstMaxZipSize.SelectedValue; long maxCompressedFileSize = long.MaxValue; if (long.TryParse(maxZipFileSize, out maxCompressedFileSize)) { this.commonApi.SetCookieValue("xliffZipSize", maxZipFileSize); } //bool toIncludeHistory = this.chkIncludeHistory.Checked; //this.commonApi.SetCookieValue("includeHistory", toIncludeHistory.ToString()); string title = txtJobTitle.Text; Ektron.Cms.BusinessObjects.Localization.L10nManager l10nMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.requestInfoRef); LocalizationExportJob exportJob = this.CreateExportJob(title, l10nMgr); exportJob.XliffVersion = xliffVersion; exportJob.MaxCompressedFileSize = maxCompressedFileSize; l10nMgr.StartExportForTranslation(exportJob); }
/// <summary> /// Queries the selected locale taxonomy and renders a list of content that is marked "Not Ready for Translation" /// </summary> private void DoNotReadyQuery() { long[] targetJobs = this.GetSelectedLocaleTaxonomyIds(); if (0 == targetJobs.Length) { rptNotReadyContent.Visible = false; lblNoResultsForNotReady.Visible = true; return; } Ektron.Cms.BusinessObjects.Localization.L10nManager l10nMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.requestInfoRef); LocalizationExportJob job = this.CreateExportJob("Content Not Ready for Translation", l10nMgr); // No localization necessary, as this job never gets created (it's just for querying and needs a name) Criteria<LocalizationExportJob> criteria = new Criteria<LocalizationExportJob>(); criteria.PagingInfo.RecordsPerPage = 50; List<Ektron.Cms.BusinessObjects.Localization.ILocalizable> items = l10nMgr.GetNotReadyList(job, criteria); if (0 == items.Count) { rptNotReadyContent.Visible = false; lblNoResultsForNotReady.Visible = true; } else { rptNotReadyContent.DataSource = items; rptNotReadyContent.DataBind(); } }
/// <summary> /// Page load to handle post back and more /// </summary> /// <param name="sender">the page object</param> /// <param name="e">The event arguments</param> protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { string language = this.Request.Form["Language"]; if (language != null) { string scriptSubtag = this.Request.Form["ScriptSubtag"]; string regionSubtag = this.Request.Form["Territory"]; string likelyLanguageTag = this.Request.Form["LikelyLanguageTag"]; if (!String.IsNullOrEmpty(likelyLanguageTag)) { this.likelyLanguageTag = new LanguageTag(likelyLanguageTag); } string loc = txtLoc.Text; int id = -1; Int32.TryParse(hdnLocaleId.Value, out id); int fallbackId = 0; Int32.TryParse(lstFallbackLoc.SelectedValue, out fallbackId); string privateUseSubtag = txtPrivateUseSubtag.Text.Trim(); LanguageTag objLangTag = new LanguageTag(language, scriptSubtag, regionSubtag, privateUseSubtag); objLangTag.RegistryUri = new Uri(Request.Url, "language-subtag-registry.xml"); string languageTag = objLangTag.ToString(); string culture = lstCulture.SelectedValue; string uiCulture = lstUICulture.SelectedValue; int lcid = 1033; System.Globalization.CultureInfo info = System.Globalization.CultureInfo.GetCultureInfo(uiCulture); if (info != null) { lcid = info.LCID; } string flagFile = rblFlag.SelectedValue; string flagUrl = CommonApi.AppImgPath + "flags/" + flagFile; string nativeName = txtNativeName.Text; string englishName = txtEnglishName.Text; bool isRightToLeft = chkIsRightToLeft.Checked; LocalizationLanguageState localeState = LocalizationLanguageState.Active; if (Enum.IsDefined(typeof(LocalizationLanguageState), hdnState.Value)) { localeState = (LocalizationLanguageState)Enum.Parse(typeof(LocalizationLanguageState), hdnState.Value); if (LocalizationLanguageState.Defined == localeState) { localeState = LocalizationLanguageState.Active; } } this.Locale = new LocaleData(id, lcid, englishName, nativeName, isRightToLeft, loc, culture, uiCulture, language, languageTag, flagFile, flagUrl, fallbackId, localeState); } } else { LanguageDesc.Text = String.Format(LanguageDesc.Text, this.GetDateOfCLDR()); System.Text.StringBuilder bcp47HyperlinkMarkup = new System.Text.StringBuilder(); using (HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter(bcp47HyperlinkMarkup))) { BCP47.RenderControl(writer); } BCP47.Visible = false; System.Text.StringBuilder rfc5646HyperlinkMarkup = new System.Text.StringBuilder(); using (HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter(rfc5646HyperlinkMarkup))) { RFC5646.RenderControl(writer); } RFC5646.Visible = false; XmlLangDescP1.Text = String.Format(XmlLangDescP1.Text, bcp47HyperlinkMarkup.ToString(), rfc5646HyperlinkMarkup.ToString()); Ektron.Cms.BusinessObjects.Localization.L10nManager l10nMgr = new Ektron.Cms.BusinessObjects.Localization.L10nManager(this.CommonApi.RequestInformationRef); MachineTranslationUndefinedPanel.Visible = !l10nMgr.IsMachineTranslationSupported; PseudoLocalizationUndefinedPanel.Visible = !l10nMgr.IsPseudoLocalizationSupported; } }