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 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 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);
    }
Exemple #5
0
    /// <summary>
    /// Creates an export job
    /// </summary>
    /// <param name="title">The title of the job</param>
    /// <param name="l10nMgr">Reference to <see cref="L10nManager"/></param>
    /// <returns>An <see cref="LocalizationExportJob"/> object</returns>
    private LocalizationExportJob CreateExportJob(string title, Ektron.Cms.BusinessObjects.Localization.L10nManager l10nMgr)
    {
        long[] taxonomyIds = this.GetSelectedLocaleTaxonomyIds();
        if (String.IsNullOrEmpty(title))
        {
            title = this.defaultJobTitle;
            if (taxonomyIds != null && 1 == taxonomyIds.Length)
            {
                long id = taxonomyIds[0];
                Ektron.Cms.API.Content.Taxonomy taxonomyApi = new Ektron.Cms.API.Content.Taxonomy();
                Ektron.Cms.TaxonomyRequest req = new Ektron.Cms.TaxonomyRequest();
                req.TaxonomyId = id;
                req.TaxonomyLanguage = this.commonApi.ContentLanguage;
                Ektron.Cms.TaxonomyData data = taxonomyApi.ReadTaxonomy(ref req);
                if (data != null)
                {
                    title = data.TaxonomyName;
                }
            }
        }

        LocalizationExportJob job = new LocalizationExportJob(title);
        job.SourceLanguageId = this.GetSelectedSourceLanguage();
        foreach (long id in taxonomyIds)
        {
            job.AddItem(LocalizableCmsObjectType.LocaleTaxonomy, id);
        }

        return job;
    }