Search in sources :

Example 26 with Glossary

use of com.google.cloud.translate.v3.Glossary in project google-cloud-java by googleapis.

the class TranslateSnippetsBeta method getGlossary.

// [END translate_list_glossary_beta]
/**
 * Retrieves a glossary.
 *
 * @param projectId - Id of the project.
 * @param location - location name.
 * @param name - Glossary name.
 */
// [START translate_get_glossary_beta]
static Glossary getGlossary(String projectId, String location, String name) {
    try (TranslationServiceClient translationServiceClient = TranslationServiceClient.create()) {
        GlossaryName glossaryName = GlossaryName.newBuilder().setProject(projectId).setLocation(location).setGlossary(name).build();
        // Call the API
        Glossary response = translationServiceClient.getGlossary(glossaryName.toString());
        System.out.format("Got: %s\n", response.getName());
        return response;
    } catch (Exception e) {
        throw new RuntimeException("Couldn't create client.", e);
    }
}
Also used : TranslationServiceClient(com.google.cloud.translate.v3beta1.TranslationServiceClient) Glossary(com.google.cloud.translate.v3beta1.Glossary) GlossaryName(com.google.cloud.translate.v3beta1.GlossaryName)

Aggregations

TranslationServiceClient (com.google.cloud.translate.v3.TranslationServiceClient)14 LocationName (com.google.cloud.translate.v3.LocationName)12 Glossary (com.google.cloud.translate.v3beta1.Glossary)10 GlossaryName (com.google.cloud.translate.v3.GlossaryName)7 TranslationServiceClient (com.google.cloud.translate.v3beta1.TranslationServiceClient)6 Test (org.junit.Test)6 GcsSource (com.google.cloud.translate.v3.GcsSource)4 TranslateTextGlossaryConfig (com.google.cloud.translate.v3.TranslateTextGlossaryConfig)4 TranslateTextRequest (com.google.cloud.translate.v3.TranslateTextRequest)4 TranslateTextResponse (com.google.cloud.translate.v3.TranslateTextResponse)4 Translation (com.google.cloud.translate.v3.Translation)4 GlossaryName (com.google.cloud.translate.v3beta1.GlossaryName)4 LocationName (com.google.cloud.translate.v3beta1.LocationName)4 BatchTranslateMetadata (com.google.cloud.translate.v3.BatchTranslateMetadata)3 BatchTranslateResponse (com.google.cloud.translate.v3.BatchTranslateResponse)3 BatchTranslateTextRequest (com.google.cloud.translate.v3.BatchTranslateTextRequest)3 GcsDestination (com.google.cloud.translate.v3.GcsDestination)3 Glossary (com.google.cloud.translate.v3.Glossary)3 InputConfig (com.google.cloud.translate.v3.InputConfig)3 OutputConfig (com.google.cloud.translate.v3.OutputConfig)3