Ejemplo n.º 1
0
        private static TemplateLanguageDetails GetTemplateLanguageDirection(string templatePath)
        {
            var document = new XmlDocument();

            document.Load(templatePath);
            var node             = document.DocumentElement?.SelectSingleNode("LanguageDirections");
            var templateLanguage = new TemplateLanguageDetails
            {
                TagrgetLanguagesCodeList = new List <string>()
            };

            if (node != null)
            {
                var sourceLanguageCode = node.ChildNodes[0].Attributes?["SourceLanguageCode"].InnerText;
                if (!string.IsNullOrEmpty(sourceLanguageCode))
                {
                    templateLanguage.SourceLanguageCode = sourceLanguageCode;
                }
                foreach (XmlNode childNode in node.ChildNodes)
                {
                    var targetLanguageCode = childNode.Attributes?["TargetLanguageCode"].InnerText;
                    if (!string.IsNullOrEmpty(targetLanguageCode))
                    {
                        templateLanguage.TagrgetLanguagesCodeList.Add(targetLanguageCode);
                    }
                }
            }
            return(templateLanguage);
        }
Ejemplo n.º 2
0
        private static bool ProjectLanguageMatchesTemplate(TemplateLanguageDetails projectTemplateLanguages, string sourceLanguage, List <Language> targetLanguages)
        {
            if (projectTemplateLanguages.SourceLanguageCode == null)
            {
                return(true);
            }

            var targetLanguagesCode = new List <string>();

            foreach (var language in targetLanguages)
            {
                targetLanguagesCode.Add(language.CultureInfo.Name);
            }

            if (!projectTemplateLanguages.SourceLanguageCode.Equals(sourceLanguage, System.StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }
            foreach (var templateTargetLanguage in projectTemplateLanguages.TagrgetLanguagesCodeList)
            {
                var sourceProjectContaisLanguage = targetLanguagesCode.Any(l => l.Equals(templateTargetLanguage, System.StringComparison.CurrentCultureIgnoreCase));
                if (!sourceProjectContaisLanguage)
                {
                    return(false);
                }
            }
            return(true);
        }