public void SetGoogleAvailableLanguages() { try { var request = new GetSupportedLanguagesRequest { ParentAsLocationName = new LocationName(_options.ProjectName, "global"), }; var response = _translationServiceClient.GetSupportedLanguages(request); foreach (var language in response.Languages) { var languageModel = new GoogleV3LanguageModel { GoogleLanguageCode = language.LanguageCode, SupportSource = language.SupportSource, SupportTarget = language.SupportTarget, CultureInfo = new CultureInfo(language.LanguageCode) }; SupportedLanguages.Add(languageModel); } } catch (Exception e) { _logger.Error($"{MethodBase.GetCurrentMethod().Name}: {e}"); } }
/// <summary>Snippet for GetSupportedLanguages</summary> public void GetSupportedLanguages() { // Snippet: GetSupportedLanguages(LocationName,string,string,CallSettings) // Create client TranslationServiceClient translationServiceClient = TranslationServiceClient.Create(); // Initialize request argument(s) LocationName parent = new LocationName("[PROJECT]", "[LOCATION]"); string displayLanguageCode = ""; string model = ""; // Make the request SupportedLanguages response = translationServiceClient.GetSupportedLanguages(parent, displayLanguageCode, model); // End snippet }
/// <summary>Snippet for GetSupportedLanguages</summary> public void GetSupportedLanguages_RequestObject() { // Snippet: GetSupportedLanguages(GetSupportedLanguagesRequest,CallSettings) // Create client TranslationServiceClient translationServiceClient = TranslationServiceClient.Create(); // Initialize request argument(s) GetSupportedLanguagesRequest request = new GetSupportedLanguagesRequest { ParentAsLocationName = new LocationName("[PROJECT]", "[LOCATION]"), }; // Make the request SupportedLanguages response = translationServiceClient.GetSupportedLanguages(request); // End snippet }
/// <summary> /// Getting a list of supported language codes /// </summary> /// <param name="projectId">Your Google Cloud Project ID.</param> public static void GetSupportedLanguagesSample(string projectId = "[Google Cloud Project ID]") { TranslationServiceClient translationServiceClient = TranslationServiceClient.Create(); GetSupportedLanguagesRequest request = new GetSupportedLanguagesRequest { ParentAsLocationName = new LocationName(projectId, "global"), }; SupportedLanguages response = translationServiceClient.GetSupportedLanguages(request); // List language codes of supported languages foreach (SupportedLanguage language in response.Languages) { Console.WriteLine($"Language Code: {language.LanguageCode}"); } }