public TextTranslationResult Adapt(TextTranslationRequest request, TextTranslationResultDto resultDto)
        {
            var translations = new List <TranslatedText>();

            for (var i = 0; i < resultDto.Translations.Count; i++)
            {
                var translationDto         = resultDto.Translations.ElementAt(i);
                var detectedSourceLanguage = TranslationLanguage.CreateByCode(translationDto.Detected_source_language);
                var textKey = request.TextParts.ElementAt(i).Key;
                var text    = translationDto.Text;

                request.IgnoreMarkup.Evaluate(markup =>
                {
                    text = text.Replace(IgnoreForTranslationMarkup.IgnoreBeginTag, markup.BeginTag, StringComparison.Ordinal);
                    text = text.Replace(IgnoreForTranslationMarkup.IgnoreEndTag, markup.EndTag, StringComparison.Ordinal);
                });

                var identifiableText = new IdentifiableText(textKey, text);
                translations.Add(new TranslatedText(detectedSourceLanguage, identifiableText));
            }

            var result = new TextTranslationResult(translations);

            return(result);
        }
        public IReadOnlyCollection <TextTranslationRequest> CreateRequests(
            string targetLanguageCode,
            Maybe <string> sourceLanguageCode,
            Maybe <IgnoreForTranslationMarkup> ignoreMarkup,
            params IdentifiableText[] textParts)
        {
            var targetLanguage = TranslationLanguage.CreateByCode(targetLanguageCode);
            var sourceLanguage = sourceLanguageCode.Evaluate(
                code => Maybe.CreateSome(TranslationLanguage.CreateByCode(code)),
                () => Maybe.CreateNone <TranslationLanguage>());

            var textPartChunks = textParts.Chunk(TextTranslationRequest.MaxTextParts);
            var result         = textPartChunks
                                 .Select(chunk => new TextTranslationRequest(targetLanguage, sourceLanguage, ignoreMarkup, chunk.ToList()))
                                 .ToList();

            return(result);
        }