Exemplo n.º 1
0
        public LanguageComparison Compare(string sourceLanguage, string targetLanguage)
        {
            var comparison = new LanguageComparison
            {
                SourceLanguage = sourceLanguage,
                TargetLanguage = targetLanguage
            };


            var balance = new Dictionary <string, List <LocalizedText> >();

            foreach (var text in Texts.Get())
            {
                if (text.Language == sourceLanguage ||
                    text.Language == targetLanguage)
                {
                    List <LocalizedText> list;
                    if (!balance.TryGetValue(text.Key, out list))
                    {
                        balance.Add(text.Key, (list = new List <LocalizedText>()));
                    }
                    list.Add(text);
                }
            }

            var singleTexts = balance.Values.Where(x => x.Count == 1).Select(x => x.First());

            comparison.MissingTexts   = singleTexts.Where(x => x.Language == sourceLanguage).ToList();
            comparison.UnmatchedTexts = singleTexts.Where(x => x.Language == targetLanguage).ToList();

            return(comparison);
        }
Exemplo n.º 2
0
        public LanguageComparison Compare(string sourceLanguage, string targetLanguage)
        {

            var comparison = new LanguageComparison
            {
                SourceLanguage = sourceLanguage,
                TargetLanguage = targetLanguage
            };


            var balance = new Dictionary<string, List<LocalizedText>>();
            foreach (var text in Texts.Get())
            {
                if (text.Language == sourceLanguage ||
                    text.Language == targetLanguage)
                {
                    List<LocalizedText> list;
                    if (!balance.TryGetValue(text.Key, out list))
                    {
                        balance.Add(text.Key, (list = new List<LocalizedText>()));
                    }
                    list.Add(text);
                }
            }

            var singleTexts = balance.Values.Where(x => x.Count == 1).Select(x => x.First());

            comparison.MissingTexts = singleTexts.Where(x => x.Language == sourceLanguage).ToList();
            comparison.UnmatchedTexts = singleTexts.Where(x => x.Language == targetLanguage).ToList();

            return comparison;
        }