/// <summary> /// Initializes a new instance of the <see cref="TranslatorServiceClient"/> class, using the specified Subscription key and the desired language. /// </summary> /// <param name="subscriptionKey">The subscription key for the Microsoft Translator Service on Azure /// </param> /// <param name="language">A string representing the supported language code to translate the text to. The code must be present in the list of codes returned from the method <see cref="GetLanguageCodesAsync"/>. If a null value is provided, the current system language is used. /// </param> /// <remarks> /// <para>You must register Microsoft Translator on https://portal.azure.com to obtain the Subscription key needed to use the service.</para> /// </remarks> /// <seealso cref="SubscriptionKey"/> /// <seealso cref="Language"/> public TranslatorServiceClient(string subscriptionKey, string language = null) { authToken = new AzureAuthToken(subscriptionKey); client = new HttpClient { BaseAddress = new Uri(BaseUrl) }; SubscriptionKey = subscriptionKey; Language = language ?? CultureInfo.CurrentCulture.Name.ToLower(); }
/// <summary> /// Initializes a new instance of the <strong>TranslatorService</strong> class, using the specified Client ID and Client Secret and the desired language. /// </summary> /// <param name="subscriptionKey">The subscription key for the Microsoft Translator Service on Azure /// </param> /// <param name="language">A string representing the supported language code to speak the text in. The code must be present in the list of codes returned from the method <see cref="GetLanguagesAsync"/>.</param> /// <remarks> /// <para>You must register Microsoft Translator on https://portal.azure.com to obtain the Subscription key needed to use the service.</para> /// </remarks> /// <seealso cref="SubscriptionKey"/> /// <seealso cref="Language"/> public TranslatorServiceClient(string subscriptionKey, string language) { authToken = new AzureAuthToken(subscriptionKey); client = new HttpClient { BaseAddress = new Uri(BASE_URL) }; SubscriptionKey = subscriptionKey; Language = language; }