private void GenerateTargetLanguageList(int ContentLanguage) { Ektron.Cms.Common.Criteria<LocaleProperty> criteria = new Ektron.Cms.Common.Criteria<LocaleProperty>( LocaleProperty.EnglishName, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending); criteria.PagingInfo.RecordsPerPage = Int32.MaxValue; criteria.AddFilter(LocaleProperty.Enabled, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, true); List<LocaleData> locales = _locApi.GetList(criteria); List<LocaleData> displayLocales = new List<LocaleData>(); if (m_intId > 0 && (CmsTranslatableType.Content == m_Type || CmsTranslatableType.Product == m_Type) ) { LocalizableCmsObjectType locObjType = LocalizableCmsObjectType.Content; switch (content_data.Type) { case (int)Ektron.Cms.Common.EkEnumeration.CMSContentType.Content: locObjType = LocalizableCmsObjectType.Content; break; case (int)Ektron.Cms.Common.EkEnumeration.CMSContentType.CatalogEntry: locObjType = LocalizableCmsObjectType.Product; break; default: locObjType = LocalizableCmsObjectType.DmsAsset; break; } List<LocalizationObjectData> localeObjectData = new List<LocalizationObjectData>(); Ektron.Cms.Framework.Localization.LocalizationObject localizationObject = new Ektron.Cms.Framework.Localization.LocalizationObject(); localeObjectData = localizationObject.GetLocalizationObjectList(locObjType, m_intId, -1); List<LocaleData> preselectedLocales = new List<LocaleData>(); locales.ForEach(delegate(LocaleData loc) { LanguageState enabled = (localeObjectData.FindAll(x => x.ObjectLanguage == loc.Id).Count > 0 ? LanguageState.Active : LanguageState.Undefined); LocaleData uiDisplayLocale = new LocaleData(loc.Id, loc.LCID, loc.EnglishName, loc.NativeName, loc.IsRightToLeft, loc.Loc, loc.Culture, loc.UICulture, loc.LangCode, loc.XmlLang, loc.FlagFile, loc.FlagUrl, loc.FallbackId, enabled); displayLocales.Add(uiDisplayLocale); }); } else { displayLocales = locales; } BoundField field = default(BoundField); LanguageGrid.Columns.Clear(); // Selected? field = new BoundField(); field.DataField = ""; //.HeaderText = "Export" field.HeaderText = "<input type=\"checkbox\" name=\"chkAll\" onclick=\"onCheckAll(this)\" checked=\"checked\" />"; field.HtmlEncode = false; field.HeaderStyle.HorizontalAlign = HorizontalAlign.Center; field.HeaderStyle.Width = new Unit(20, UnitType.Pixel); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Center; LanguageGrid.Columns.Add(field); // Flag Icon field = new BoundField(); field.DataField = "FlagFile"; field.HeaderText = ""; field.HeaderStyle.Width = new Unit(20, UnitType.Pixel); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Center; LanguageGrid.Columns.Add(field); // Language Name field = new BoundField(); field.DataField = "CombinedName"; field.HtmlEncode = false; field.SortExpression = LocaleProperty.EnglishName.ToString(); field.HeaderText = GetMessage("generic name"); field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; field.ItemStyle.Wrap = false; LanguageGrid.Columns.Add(field); // Loc field = new BoundField(); field.DataField = "Loc"; field.SortExpression = LocaleProperty.Loc.ToString(); field.HeaderText = GetMessage("lbl loc"); field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; field.HeaderStyle.Width = new Unit(6, UnitType.Em); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Left; LanguageGrid.Columns.Add(field); //// Language Code //field = new BoundField(); //field.DataField = "XmlLang"; //// or "BrowserCode" //field.SortExpression = EkDS.SortBy.XmlLang.ToString(); //// or .BrowserCode //field.HeaderText = GetMessage("lbl code"); //field.HeaderStyle.HorizontalAlign = HorizontalAlign.Left; //field.HeaderStyle.Width = new Unit(6, UnitType.Em); //field.ItemStyle.Wrap = false; //field.ItemStyle.HorizontalAlign = HorizontalAlign.Left; //LanguageGrid.Columns.Add(field); // Language ID (decimal) field = new BoundField(); field.DataField = "Id"; field.SortExpression = LocaleProperty.Id.ToString(); field.HeaderText = GetMessage("generic ID"); field.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; field.HeaderStyle.CssClass = "right"; field.HeaderStyle.Width = new Unit(8, UnitType.Em); field.ItemStyle.Wrap = false; field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; field.ItemStyle.CssClass = "right"; LanguageGrid.Columns.Add(field); //// Language ID (hex) //field = new BoundField(); //field.DataField = "LanguageID"; //field.HtmlEncode = false; //// necessary to make DataFormatString effective //field.DataFormatString = "{0:x4}"; //field.HeaderText = GetMessage("lbl hex"); //field.HeaderStyle.HorizontalAlign = HorizontalAlign.Right; //field.HeaderStyle.Width = new Unit(4, UnitType.Em); //field.ItemStyle.Wrap = false; //field.ItemStyle.HorizontalAlign = HorizontalAlign.Right; //LanguageGrid.Columns.Add(field); // FireFox: border between cells is a result of the <table rules="all" attribute, which I do not know how to eliminate. LanguageGrid.RowDataBound += LanguageGrid_RowDataBound; LanguageGrid.DataSource = displayLocales; LanguageGrid.DataBind(); }
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; }
/// <param name="addRemoveReplace">true for add, false for remove, null for replace</param> protected void SetLocales(List<long> selections, List<int> selectedLocales, int defaultLocale, bool? addRemoveReplace) { Ektron.Cms.Framework.Localization.LocaleManager locale = new Ektron.Cms.Framework.Localization.LocaleManager(); Ektron.Cms.Framework.Localization.LocalizationObject lobj = new Ektron.Cms.Framework.Localization.LocalizationObject(); List<Ektron.Cms.Localization.LocaleData> locales = locale.GetEnabledLocales(); // Loop through each of the selected content items to try and find selected locales List<int> contentLocales = new List<int>(); if (!selectedLocales.Contains(defaultLocale)) selectedLocales.Add(defaultLocale); selectedLocales.Sort(); List<int> localesToDelete = new List<int>(); List<int> localesToAdd = new List<int>(); List<Ektron.Cms.Localization.LocalizationObjectData> localeData = new List<Ektron.Cms.Localization.LocalizationObjectData>(); foreach (long item in selections) { Ektron.Cms.Localization.LocalizableCmsObjectType objectType = Ektron.Cms.Localization.LocalizableCmsObjectType.Content; contentLocales = lobj.GetObjectLanguages(Ektron.Cms.Localization.LocalizableCmsObjectType.Content, item); if (contentLocales.Count == 0) { objectType = Ektron.Cms.Localization.LocalizableCmsObjectType.DmsAsset; contentLocales = lobj.GetObjectLanguages(Ektron.Cms.Localization.LocalizableCmsObjectType.DmsAsset, item); } bool skip = true; if (addRemoveReplace == null && !LocaleListsMatch(selectedLocales, contentLocales)) skip = false; if (addRemoveReplace == true && !LocaleListContains(contentLocales, selectedLocales)) skip = false; if (addRemoveReplace == false && LocaleListContains(contentLocales, selectedLocales)) skip = false; if (!skip) { localeData = lobj.GetLocalizationObjectList(objectType, item, -1); localesToDelete.Clear(); localesToAdd.Clear(); if (addRemoveReplace == null || addRemoveReplace == true) foreach (int i in selectedLocales) if (!contentLocales.Contains(i)) localesToAdd.Add(i); if (addRemoveReplace == null) foreach (int i in contentLocales) if (!selectedLocales.Contains(i)) localesToDelete.Add(i); if (addRemoveReplace == false) foreach (int i in contentLocales) if (selectedLocales.Contains(i)) localesToDelete.Add(i); foreach (int i in localesToDelete) foreach (Ektron.Cms.Localization.LocalizationObjectData ldata in localeData) if (ldata.ObjectLanguage == i) lobj.Delete(ldata.Id); foreach (int i in localesToAdd) lobj.MarkReadyForTranslation(objectType, item, i); } } }