예제 #1
0
        /// <summary>
        /// Generate new .xml reports( the reports will be imported manually in Helix).
        /// The already reports which are generated through TargetWordCount app are not compatible in Helix
        /// The app should support reports name like this: Target Word Count sv-SE_en-us.xml and Target Word Count sv-SE_en-US.xml
        /// </summary>
        /// <param name="languageDirection">language direction</param>
        /// <param name="projectFiles">project files for the language direction on which the batch task is running</param>
        public static void GenerateHelixReport(LanguageDirection languageDirection, List <ProjectFile> projectFiles)
        {
            var currentProject = GetProjectController()?.CurrentProject;
            var projectInfo    = currentProject?.GetProjectInfo();

            if (projectInfo != null)
            {
                var directoryFolder = $@"{projectInfo.LocalProjectFolder}{Constants.ReportFolder}";
                if (!Directory.Exists(directoryFolder))
                {
                    Directory.CreateDirectory(directoryFolder);
                }

                var directoryInfo = new DirectoryInfo($@"{projectInfo.LocalProjectFolder}{Constants.Reports}");

                var fileInfo = directoryInfo
                               .GetFiles()
                               .OrderByDescending(f => f.LastWriteTime)
                               .FirstOrDefault(n => n.Name.ToLower().StartsWith($@"{Constants.TargetWordCount.ToLower()} {languageDirection.SourceLanguage.CultureInfo.Name.ToLower()}_{languageDirection.TargetLanguage.CultureInfo.Name.ToLower()}"));

                if (fileInfo != null)
                {
                    var helixReportPath = Path.Combine(directoryFolder, Path.GetFileName(fileInfo.FullName));
                    if (File.Exists(helixReportPath))
                    {
                        File.Delete(helixReportPath);
                    }
                    File.Create(helixReportPath).Dispose();

                    // Create the new helix report xml report structure as the one from the Studio WordCount.xml report
                    CreateReportDocument(projectInfo, languageDirection, helixReportPath, fileInfo, projectFiles);
                }
            }
        }
        protected override void UpdateAlignment(TextMeshPro text, LanguageDirection direction)
        {
            if (IsOppositeDirection(text.alignment, direction))
            {
                switch (text.alignment)
                {
                case TextAlignmentOptions.TopLeft:
                    text.alignment = TextAlignmentOptions.TopRight;
                    break;

                case TextAlignmentOptions.TopRight:
                    text.alignment = TextAlignmentOptions.TopLeft;
                    break;

                case TextAlignmentOptions.Left:
                    text.alignment = TextAlignmentOptions.Right;
                    break;

                case TextAlignmentOptions.Right:
                    text.alignment = TextAlignmentOptions.Left;
                    break;

                case TextAlignmentOptions.BottomLeft:
                    text.alignment = TextAlignmentOptions.BottomRight;
                    break;

                case TextAlignmentOptions.BottomRight:
                    text.alignment = TextAlignmentOptions.BottomLeft;
                    break;
                }
            }
        }
예제 #3
0
        public static Dictionary <string, LanguageDirection> LoadLanguageDirections(XmlDocument doc)
        {
            var languages = new Dictionary <string, LanguageDirection>();
            var languageeDirectionNode = doc.SelectNodes("/Project/LanguageDirections/LanguageDirection");

            if (languageeDirectionNode == null)
            {
                return(languages);
            }
            foreach (var item in languageeDirectionNode)
            {
                var node = (XmlNode)item;
                if (node.Attributes == null)
                {
                    continue;
                }
                var lang = new LanguageDirection
                {
                    Guid       = node.Attributes["Guid"].Value,
                    TargetLang = CultureInfo.GetCultureInfo(node.Attributes["TargetLanguageCode"].Value)
                };
                languages.Add(lang.Guid, lang);
            }

            return(languages);
        }
예제 #4
0
        public static Dictionary <string, LanguageDirection> LoadLanguageDirections(XmlDocument doc)
        {
            var languages = new Dictionary <string, LanguageDirection>();

            try
            {
                var languageeDirectionNode = doc.SelectNodes("/Project/LanguageDirections/LanguageDirection");

                if (languageeDirectionNode == null)
                {
                    return(languages);
                }
                foreach (var item in languageeDirectionNode)
                {
                    var node = (XmlNode)item;
                    if (node.Attributes == null)
                    {
                        continue;
                    }
                    var lang = new LanguageDirection
                    {
                        Guid       = node.Attributes["Guid"].Value,
                        TargetLang = CultureInfo.GetCultureInfo(node.Attributes["TargetLanguageCode"].Value)
                    };
                    languages.Add(lang.Guid, lang);
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"LoadLanguageDirections method: {ex.Message}\n {ex.StackTrace}");
            }
            return(languages);
        }
예제 #5
0
        protected override void UpdateAlignment(Text text, LanguageDirection direction)
        {
            if (IsOppositeDirection(text.alignment, direction))
            {
                switch (text.alignment)
                {
                case TextAnchor.UpperLeft:
                    text.alignment = TextAnchor.UpperLeft;
                    break;

                case TextAnchor.UpperRight:
                    text.alignment = TextAnchor.UpperRight;
                    break;

                case TextAnchor.MiddleLeft:
                    text.alignment = TextAnchor.MiddleRight;
                    break;

                case TextAnchor.MiddleRight:
                    text.alignment = TextAnchor.MiddleLeft;
                    break;

                case TextAnchor.LowerLeft:
                    text.alignment = TextAnchor.LowerRight;
                    break;

                case TextAnchor.LowerRight:
                    text.alignment = TextAnchor.LowerLeft;
                    break;
                }
            }
        }
예제 #6
0
        /// <summary>
        /// <see cref="M:System.Object.Equals(object)"/>
        /// </summary>
        /// <param name="obj">The object to compare with the current object.</param>
        /// <returns>true if the specified object is equal to the current object;
        /// otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj.GetType() != this.GetType())
            {
                return(false);
            }

            GoogleLanguageDirection other = obj as GoogleLanguageDirection;

            if (other == null)
            {
                return(false);
            }

            if (!LanguageDirection.Equals(other.LanguageDirection))
            {
                return(false);
            }

            return(true);    // no settings yet so always true
        }
예제 #7
0
        static ToolStripMenuItem FillLanguages(Dictionary <string, string> source, ToolStripDropDownItem btLanguage, bool isFrom)
        {
            #region commonLangs
            //<option selected="selected" dir="ltr" style="text-align:left" lang="en" value="/">English</option>
            //<option dir="ltr" style="text-align:left" lang="gr" value="http://gr.euronews.com/">Ελληνικά</option>
            //<option dir="ltr" style="text-align:left" lang="hu" value="http://hu.euronews.com/">Magyar</option>
            //<option dir="ltr" style="text-align:left" lang="fr" value="http://fr.euronews.com/">Français</option>
            //<option dir="ltr" style="text-align:left" lang="de" value="http://de.euronews.com/">Deutsch</option>
            //<option dir="ltr" style="text-align:left" lang="it" value="http://it.euronews.com/">Italiano</option>
            //<option dir="ltr" style="text-align:left" lang="es" value="http://es.euronews.com/">Español</option>
            //<option dir="ltr" style="text-align:left" lang="pt" value="http://pt.euronews.com/">Português</option>
            //<option dir="ltr" style="text-align:left" lang="pl" value="http://pl.euronews.com/">Polski</option>
            //<option dir="ltr" style="text-align:left" lang="ru" value="http://ru.euronews.com/">Pусский</option>
            //<option dir="ltr" style="text-align:left" lang="ua" value="http://ua.euronews.com/">Українська</option>
            //<option dir="ltr" style="text-align:left" lang="tr" value="http://tr.euronews.com/">Türkçe</option>
            //<option dir="rtl" style="text-align:right" lang="ar" value="http://arabic.euronews.com/">عــربي</option> ar
            //<option dir="rtl" style="text-align:right" lang="pe" value="http://persian.euronews.com/">فارسی</option> fa

            string[] commonLangs = new string[] { "en", "gr", "hu", "fr", "de", "it", "es", "pt", "pl", "ru", "ua", "tr", "ar", "fa" };
            #endregion

            string dir = isFrom ?
                         LanguageDirection.Split(PairSeparator)[0] :
                         LanguageDirection.Split(PairSeparator)[1];

            ToolStripMenuItem currentItem = null;
            ToolStripMenuItem miOther     = new ToolStripMenuItem("Other languages");

            foreach (KeyValuePair <string, string> pair in source)
            {
                ToolStripMenuItem mi = new ToolStripMenuItem(pair.Key + " : " + pair.Value);
                mi.CheckOnClick = true;
                mi.Tag          = isFrom; // indication From or To
                mi.Click       += new EventHandler(ChangedLangDirOnClick);
                if (dir == pair.Value)
                {
                    currentItem = mi;
                    mi.Checked  = true;
                }
                if (Array.IndexOf(commonLangs, pair.Value) != -1)
                {
                    btLanguage.DropDownItems.Add(mi);
                }
                else
                {
                    miOther.DropDownItems.Add(mi);
                }
            }

            btLanguage.DropDownItems.Add(miOther);

            btLanguage.DropDownOpening += new EventHandler(btLanguage_DropDownOpening);
            return(currentItem);
        }
예제 #8
0
        static void ChangedLangDirOnClick(object sender, EventArgs e)
        {
            ToolStripMenuItem miSender = (ToolStripMenuItem)sender;
            string            lang     = miSender.Text.Split(':')[1].Trim();

            if ((Boolean)miSender.Tag) // isFrom
            {
                LanguageDirection = lang + PairSeparator + LanguageDirection.Split(PairSeparator)[1];
            }
            else
            {
                LanguageDirection = LanguageDirection.Split(PairSeparator)[0] + PairSeparator + lang;
            }
        }
예제 #9
0
        public static string SerializeLanguageDirection(LanguageDirection dir)
        {
            switch (dir)
            {
            case LanguageDirection.LeftToRight:
                return("ltr");

            case LanguageDirection.RightToLeft:
                return("rtl");

            default:
                return(null);
            }
        }
예제 #10
0
    protected override void UpdateAlignment(UILabel text, LanguageDirection direction)
    {
        if (IsOppositeDirection(text.alignment, direction))
        {
            switch (text.alignment)
            {
            case NGUIText.Alignment.Left:
                text.alignment = NGUIText.Alignment.Right;
                break;

            case NGUIText.Alignment.Right:
                text.alignment = NGUIText.Alignment.Left;
                break;
            }
        }
    }
예제 #11
0
        //THIS IS DEPRECATED, REPLACED WITH SEGMENT CHANGE HANDLER EVENT
        //This function starts translating all segments in the document once the document is opened,
        //so that the translator won't have to wait for the translation to finish when opening a segment.
        //Note that Studio contains a feature called LookAhead which attempts to do a similar thing, but
        //LookAhead appears to be buggy with TMs etc., so it's better to rely on a custom caching system.
        private static void TranslateDocumentSegments(Document doc, LanguageDirection langPair, OpusCatOptions options)
        {
            var visitor = new OpusCatMarkupDataVisitor();
            EditorController editorController = SdlTradosStudio.Application.GetController <EditorController>();

            foreach (var segmentPair in doc.SegmentPairs)
            {
                if (segmentPair.Properties.ConfirmationLevel == Sdl.Core.Globalization.ConfirmationLevel.Unspecified)
                {
                    visitor.Reset();
                    segmentPair.Source.AcceptVisitor(visitor);
                    var sourceText = visitor.PlainText;

                    var sourceCode = langPair.SourceLanguage.CultureInfo.TwoLetterISOLanguageName;
                    var targetCode = langPair.TargetLanguage.CultureInfo.TwoLetterISOLanguageName;
                    var langpair   = $"{sourceCode}-{targetCode}";

                    //This will generate the translation and cache it for later use
                    OpusCatMTServiceHelper.Translate(options, sourceText, sourceCode, targetCode, options.modelTag);
                }
            }

            //processedDocuments[langPair].Add(doc);
        }
예제 #12
0
 public string SerializeState()
 {
     return(LanguageDirection.ToString());
 }
예제 #13
0
        private static void segmentChanged(LanguageDirection langDir, object sender, EventArgs e)
        {
            var doc = (Document)sender;

            //There are some "segments" the Trados editor view which are not proper segments, like
            //the start of document tag
            if (doc.ActiveSegmentPair == null)
            {
                return;
            }
            var visitor = new OpusCatMarkupDataVisitor();

            var activeOpusCatOptions = OpusCatProvider.GetProjectOpusCatOptions(doc.Project, langDir);

            IEnumerable <OpusCatOptions> activeOpusCatOptionsWithPregenerate;

            if (activeOpusCatOptions == null)
            {
                activeOpusCatOptionsWithPregenerate = null;
            }
            else
            {
                activeOpusCatOptionsWithPregenerate = activeOpusCatOptions.Where(x => x.pregenerateMt);
            }
            //If there is no active OPUS CAT provider, unsubscribe this handler (there's probably no event in Trados
            //API for removing a translation provider from a project, so this is the only way to unsubscribe
            //after translation provider has been removed.
            if (activeOpusCatOptionsWithPregenerate == null || !activeOpusCatOptionsWithPregenerate.Any())
            {
                OpusCatProvider.ClearSegmentHandlers();
                return;
            }

            var sourceSegmentTexts = new List <string>();

            var nextSegmentPairs = doc.SegmentPairs.SkipWhile(x =>
                                                              !(x.Properties.Id == doc.ActiveSegmentPair.Properties.Id &&
                                                                x.GetParagraphUnitProperties().ParagraphUnitId == doc.ActiveSegmentPair.GetParagraphUnitProperties().ParagraphUnitId));

            var segmentsNeeded = activeOpusCatOptionsWithPregenerate.Max(x => x.pregenerateSegmentCount);

            foreach (var segmentPair in nextSegmentPairs)
            {
                if (sourceSegmentTexts.Count == segmentsNeeded)
                {
                    break;
                }

                //Also preorder translations for Draft segments, since quite often there will be draft content
                //provided in segments where having MT is still desirable. This could also be an option.
                if (segmentPair.Properties.ConfirmationLevel == Sdl.Core.Globalization.ConfirmationLevel.Unspecified ||
                    segmentPair.Properties.ConfirmationLevel == Sdl.Core.Globalization.ConfirmationLevel.Draft)
                {
                    visitor.Reset();
                    segmentPair.Source.AcceptVisitor(visitor);
                    var sourceText = visitor.PlainText;
                    sourceSegmentTexts.Add(sourceText);
                }
            }

            var sourceCode = langDir.SourceLanguage.CultureInfo.TwoLetterISOLanguageName;
            var targetCode = langDir.TargetLanguage.CultureInfo.TwoLetterISOLanguageName;

            foreach (var options in activeOpusCatOptionsWithPregenerate)
            {
                //The preorder method doesn't wait for the translation, so the requests return quicker
                var sourceSegmentTextsNeeded = sourceSegmentTexts.Take(options.pregenerateSegmentCount).ToList();
                OpusCatMTServiceHelper.PreOrderBatch(options, sourceSegmentTextsNeeded, sourceCode, targetCode, options.modelTag);
            }
        }
예제 #14
0
        /// <summary>
        /// Create the ..\Reports\StudioTargetWordCount\{targetWordCountReportName}.xml structure based on the Studio WordCount.xml report structure
        /// The WordCount.xml structure is needed, because it is compatible with Helix import process,
        /// and the ..\Reports\StudioTargetWordCount\{targetWordCountReportName}.xml will be imported in Helix
        /// </summary>
        /// <param name="projectInfo">project information</param>
        /// <param name="languageDirection">file language direction</param>
        /// <param name="helixReportPath">the new TargetWordCount xml report path which will be used in Helix</param>
        /// <param name="fileInfo">file info</param>
        /// <param name="projectFiles">list of the project files on which the batch task is running</param>
        private static void CreateReportDocument(
            ProjectInfo projectInfo,
            LanguageDirection languageDirection,
            string helixReportPath,
            FileInfo fileInfo,
            List <ProjectFile> projectFiles)
        {
            var doc           = new XmlDocument();
            int totalSegments = 0;
            int totalWords    = 0;
            int number;

            var taskElement = doc.CreateElement(string.Empty, "task", string.Empty);

            taskElement.SetAttribute("name", "wordcount");
            doc.AppendChild(taskElement);

            var taskInfoElement = doc.CreateElement(string.Empty, "taskInfo", string.Empty);

            taskInfoElement.SetAttribute("taskId", Guid.NewGuid().ToString());
            taskInfoElement.SetAttribute("runAt", DateTime.UtcNow.ToString());
            taskInfoElement.SetAttribute("runTime", "Less than 1 second");
            taskElement.AppendChild(taskInfoElement);

            var projectElement = doc.CreateElement(string.Empty, "project", string.Empty);

            projectElement.SetAttribute("name", projectInfo.Name);
            projectElement.SetAttribute("number", projectInfo.Id != null ? projectInfo.Id.ToString() : Guid.NewGuid().ToString());
            taskInfoElement.AppendChild(projectElement);

            var languageElement = doc.CreateElement(string.Empty, "language", string.Empty);

            languageElement.SetAttribute("lcid", languageDirection.TargetLanguage.CultureInfo.LCID.ToString());
            languageElement.SetAttribute("name", languageDirection.TargetLanguage.DisplayName);
            taskElement.AppendChild(languageElement);

            // take the files values from the Target Word Count {sourceLanguage_languageDirection.TargetLanguage}.xml report
            // and add the files nodes to the doc for each projectFiles on which the TargetWordCount batch task had been run.
            var document = new XmlDocument();

            document.Load(fileInfo.FullName);

            foreach (var projectFile in projectFiles)
            {
                var fileNode = document.SelectSingleNode($"//File[@Name='{projectFile.Name}']");
                if (fileNode != null)
                {
                    var totalNodeAttributes = fileNode.SelectSingleNode("Total") != null?fileNode.SelectSingleNode("Total").Attributes : null;

                    if (totalNodeAttributes.Count > 0)
                    {
                        var fileElement = doc.CreateElement(string.Empty, "file", string.Empty);
                        fileElement.SetAttribute("name", projectFile.Name);
                        fileElement.SetAttribute("guid", projectFile.Id.ToString());
                        languageElement.AppendChild(fileElement);

                        SetNewTotalElement(doc, totalNodeAttributes["Segments"].Value, totalNodeAttributes["Count"].Value, fileElement);
                        totalSegments += int.TryParse(totalNodeAttributes["Segments"].Value, out number) != false?int.Parse(totalNodeAttributes["Segments"].Value) : 0;

                        totalWords += int.TryParse(totalNodeAttributes["Count"].Value, out number) != false?int.Parse(totalNodeAttributes["Count"].Value) : 0;
                    }
                }
            }
            var batchTotalElement = doc.CreateElement(string.Empty, "batchTotal", string.Empty);

            taskElement.AppendChild(batchTotalElement);
            SetNewTotalElement(doc, totalSegments.ToString(), totalWords.ToString(), batchTotalElement);

            doc.Save(helixReportPath);
        }
예제 #15
0
        /// <summary>
        /// Create the ..\Reports\StudioTargetWordCount\{targetWordCountReportName}.xml structure based on the Studio WordCount.xml report structure
        /// The WordCount.xml structure is needed, because it is compatible with Helix import process,
        /// and the ..\Reports\StudioTargetWordCount\{targetWordCountReportName}.xml will be imported in Helix
        /// </summary>
        /// <param name="projectInfo">project information</param>
        /// <param name="languageDirection">file language direction</param>
        /// <param name="helixReportPath">the new TargetWordCount xml report path which will be used in Helix</param>
        /// <param name="fileInfo">file info</param>
        /// <param name="projectFiles">list of the project files on which the batch task is running</param>
        private static void CreateReportDocument(
            ProjectInfo projectInfo,
            LanguageDirection languageDirection,
            string helixReportPath,
            FileInfo fileInfo,
            List <ProjectFile> projectFiles)
        {
            var doc           = new XmlDocument();
            var totalSegments = 0;
            var totalWords    = 0;

            var taskElement = doc.CreateElement(string.Empty, Constants.Task, string.Empty);

            taskElement.SetAttribute(Constants.Name, Constants.WordCount);
            doc.AppendChild(taskElement);

            var taskInfoElement = doc.CreateElement(string.Empty, Constants.TaskInfo, string.Empty);

            taskInfoElement.SetAttribute(Constants.TaskId, Guid.NewGuid().ToString());
            taskInfoElement.SetAttribute(Constants.RunAt, DateTime.UtcNow.ToString());
            taskInfoElement.SetAttribute(Constants.RunTime, Constants.OneSecondLess);
            taskElement.AppendChild(taskInfoElement);

            var projectElement = doc.CreateElement(string.Empty, Constants.Project, string.Empty);

            projectElement.SetAttribute(Constants.Name, projectInfo.Name);
            projectElement.SetAttribute(Constants.Number, projectInfo.Id != null ? projectInfo.Id.ToString() : Guid.NewGuid().ToString());
            taskInfoElement.AppendChild(projectElement);

            var languageElement = doc.CreateElement(string.Empty, Constants.Language, string.Empty);

            languageElement.SetAttribute(Constants.Lcid, languageDirection.TargetLanguage.CultureInfo.LCID.ToString());
            languageElement.SetAttribute(Constants.Name, languageDirection.TargetLanguage.DisplayName);
            taskInfoElement.AppendChild(languageElement);

            // take the files values from the Target Word Count {sourceLanguage_languageDirection.TargetLanguage}.xml report
            // and add the files nodes to the doc for each projectFiles on which the TargetWordCount batch task had been run.
            var document = new XmlDocument();

            document.Load(fileInfo.FullName);

            foreach (var projectFile in projectFiles)
            {
                var fileNode = document.SelectSingleNode($"{Constants.FilePath}'{projectFile.Name}']");
                if (fileNode != null)
                {
                    var totalNodeAttributes = fileNode.SelectSingleNode(Constants.Total) != null?fileNode.SelectSingleNode(Constants.Total).Attributes : null;

                    if (totalNodeAttributes?.Count > 0)
                    {
                        var fileElement = doc.CreateElement(string.Empty, Constants.File, string.Empty);
                        fileElement.SetAttribute(Constants.Name, projectFile.Name);
                        fileElement.SetAttribute(Constants.Guid, projectFile.Id.ToString());
                        taskElement.AppendChild(fileElement);

                        var analyseElement = doc.CreateElement(string.Empty, Constants.Analyse, string.Empty);
                        fileElement.AppendChild(analyseElement);

                        SetAnalyseElement(doc, Constants.Perfect, Constants.Zero, Constants.Zero, analyseElement);
                        SetAnalyseElement(doc, Constants.InContextExact, Constants.Zero, Constants.Zero, analyseElement);
                        SetAnalyseElement(doc, Constants.Repeated, Constants.Zero, Constants.Zero, analyseElement);
                        SetAnalyseElement(doc, Constants.LowTotal, totalNodeAttributes[Constants.Segments].Value, totalNodeAttributes[Constants.Count].Value, analyseElement);
                        SetAnalyseElement(doc, Constants.New, totalNodeAttributes[Constants.Segments].Value, totalNodeAttributes[Constants.Count].Value, analyseElement);
                        totalSegments += int.TryParse(totalNodeAttributes[Constants.Segments].Value, out _) ? int.Parse(totalNodeAttributes[Constants.Segments].Value) : 0;
                        totalWords    += int.TryParse(totalNodeAttributes[Constants.Count].Value, out _) ? int.Parse(totalNodeAttributes[Constants.Count].Value) : 0;
                    }
                }
            }
            var batchTotalElement = doc.CreateElement(string.Empty, Constants.BatchTotal, string.Empty);

            taskElement.AppendChild(batchTotalElement);
            var batchAnalyseElement = doc.CreateElement(string.Empty, Constants.Analyse, string.Empty);

            batchTotalElement.AppendChild(batchAnalyseElement);

            SetAnalyseElement(doc, Constants.LowTotal, totalSegments.ToString(), totalWords.ToString(), batchAnalyseElement);

            doc.Save(helixReportPath);
        }
예제 #16
0
 private string CreateReportName(LanguageDirection langDirection)
 {
     return($"Target Word Count {langDirection.SourceLanguage.IsoAbbreviation}_{langDirection.TargetLanguage.IsoAbbreviation}");
 }
예제 #17
0
 /// <summary>
 /// <see cref="object.GetHashCode()"/>
 /// </summary>
 /// <returns>A hash code for this object</returns>
 public override int GetHashCode()
 {
     // The name and language direction can be used to hash the configuration of this object
     return((Name + LanguageDirection.ToString()).GetHashCode());
 }
예제 #18
0
        private static IEnumerable <OpusCatOptions> GetProjectOpusCatOptions(FileBasedProject project, LanguageDirection langDir)
        {
            //Make sure that the project has an active OPUS-CAT translation provider included in it.
            var projectTpConfig = project.GetTranslationProviderConfiguration();

            //Check if language-specific tp config overrides the main config
            var targetLanguageTpConfig = project.GetTranslationProviderConfiguration(langDir.TargetLanguage);

            IEnumerable <TranslationProviderCascadeEntry> activeOpusCatTps;

            if (targetLanguageTpConfig.OverrideParent)
            {
                activeOpusCatTps = targetLanguageTpConfig.Entries.Where(
                    x =>
                    x.MainTranslationProvider.Enabled &&
                    x.MainTranslationProvider.Uri.OriginalString.Contains(OpusCatTranslationProviderScheme)
                    );
            }
            else
            {
                activeOpusCatTps = projectTpConfig.Entries.Where(
                    x =>
                    x.MainTranslationProvider.Enabled &&
                    x.MainTranslationProvider.Uri.OriginalString.Contains(OpusCatTranslationProviderScheme)
                    );
            }

            if (activeOpusCatTps.Any())
            {
                var activeOpusCatOptions = activeOpusCatTps.Select(x => new OpusCatOptions(x.MainTranslationProvider.Uri));
                return(activeOpusCatOptions);
            }
            else
            {
                return(null);
            }
        }
 protected abstract void UpdateAlignment(T component, LanguageDirection direction);
예제 #20
0
 private bool IsOppositeDirection(TextAlignment alignment, LanguageDirection direction)
 {
     return (direction == LanguageDirection.LeftToRight && IsAlignmentRight(alignment)) || (direction == LanguageDirection.RightToLeft && IsAlignmentLeft(alignment));
 }
예제 #21
0
 private bool IsOppositeDirection(TextAnchor alignment, LanguageDirection direction)
 {
     return((direction == LanguageDirection.LeftToRight && IsAlignmentRight(alignment)) || (direction == LanguageDirection.RightToLeft && IsAlignmentLeft(alignment)));
 }
예제 #22
0
 private string CreateKey(LanguageDirection langDir)
 {
     return(langDir.SourceLanguage.IsoAbbreviation + langDir.TargetLanguage.IsoAbbreviation);
 }