Ejemplo n.º 1
0
        public async Task ExecuteAsync()
        {
            var request = _requestBuilderFactory
                          .StartBuilding(TranslationLanguage.English)
                          .WithTextPart("Tra", "Hallo Welt")
                          .Build();

            var translation = await _deeplTranslator.TranslateAsync(request);

            var translatedText = translation.TranslatedTexts.Single();

            _consoleWriter.WriteLine($"Detected source language: {translatedText.DetectedSourceLanguage}");
            _consoleWriter.WriteLine($"Text: {translatedText.TextPart.Text}");
        }
Ejemplo n.º 2
0
        public async Task ExecuteAsync()
        {
            var request = _requestBuilderFactory
                          .StartBuilding(TranslationLanguage.German)
                          .WithSourceLanguage(TranslationLanguage.English)
                          .WithTextPart("Text1", "Hello world")
                          .WithTextPart("Text2", "This is a sentence to verify the translation")
                          .Build();

            var translation = await _deeplTranslator.TranslateAsync(request);

            _consoleWriter.WriteLine($"Text1: {translation["Text1"].TextPart.Text}");
            _consoleWriter.WriteLine($"Text2: {translation["Text2"].TextPart.Text}");
        }
Ejemplo n.º 3
0
        public async Task ExecuteAsync()
        {
            var request = _requestBuilderFactory
                          .StartBuilding(TranslationLanguage.English)
                          .WithSourceLanguage(TranslationLanguage.German)
                          .WithTextPart("Tra", "Hallo Welt {{ Dieser Text hier wird nicht übersetzt }}. Dieser hier aber schon.")
                          .WithIgnoreMarkupTag("{{", "}}")
                          .Build();

            var translation = await _deeplTranslator.TranslateAsync(request);

            var translatedText = translation.TranslatedTexts.Single();

            _consoleWriter.WriteLine($"Text: {translatedText.TextPart.Text}");
        }