Exemplo n.º 1
0
        private void Translate()
        {
            // Prompts you for text to translate. If you'd prefer, you can
            // provide a string as textToTranslate.
            Console.WriteLine("Type the phrase you'd like to translate? ");
            string textToTranslate = Console.ReadLine();

            Console.WriteLine("Enter 'from' language (blank for auto-detect):");
            var from = Console.ReadLine();

            Console.WriteLine("Enter the BCP 47 language tag(s):");
            var deserializedOutput = _service.TranslateTextAsync(textToTranslate, Console.ReadLine()?.Split(',', StringSplitOptions.RemoveEmptyEntries), from).Result.Object;

            Console.WriteLine(JsonConvert.SerializeObject(deserializedOutput, Formatting.Indented));
        }