I am excited most by the extensibility and flexibility of the Nuxeo platform and integrating with Google Cloud Machine Learning products is a classic example of how powerful the platform truly is.

We recently delved into a fun integration with Google Cloud’s Natural Language and Translation APIs, making use of our previous work integrating with Google Cloud’s Vision API. The results were successful and we are hoping they will be useful to anyone interested in leveraging Google’s machine learning work to derive information from text and/or translate text (or even entire documents) to and from multiple supported languages (100+ supported languages). Similar to the Vision API integration, Google Cloud exposes operations within a REST API, which both the Translation and Natural Language services are built around. Of course, extending these services to accept other providers is possible as they, like much of the platform, are extensible.

Google Cloud Translation API

Integration Google Cloud graciously provides a Java client library so that we can more easily make requests to their API and retrieve responses. With our custom provider, we retrieve the Translation Service and can translate text by calling the translate method.

Translation com.google.cloud.translate.Translate.translate(String text, TranslateOption... options)
Translates the provided texts.

Example of translating a text:
Translation translation = translate.translate("Hola Mundo!");

Example of translating a text, specifying source and target  language:
Translation translation = translate.translate("Hola Mundo!", TranslateOption.sourceLanguage("es"), TranslateOption.targetLanguage("de"));

text the text to translate

An object containing information on the language translation

TranslateException - upon failure or if TranslateOption.model(String) is used by a non-whitelisted user


protected Translate getTranslationServiceClient() throws IOException {
    if (translationServiceClient == null) {
        synchronized (this) {
            if (translationServiceClient == null) {
                try (InputStream is = new FileInputStream(new File(getCredentialFilePath()))) {     
                    final GoogleCredentials myCredentials = GoogleCredentials.fromStream(is);
        translationServiceClient = TranslateOptions.newBuilder().setCredentials(myCredentials).build().getService();
    } catch (IOException ioe) {
        throw new NuxeoException(ioe);
    return translationServiceClient;

public TranslationResponse translateText(String text, String sourceLanguage, String targetLanguage) throws IOException {
    Translate translationService = getTranslationServiceClient();
    Translation response = translationService.translate(text);
    GoogleTranslationResponse gtr = new GoogleTranslationResponse(response);
    return gtr;

The particular use case we had here was to ingest documents that potentially contain text in other languages. We felt that detecting the source language and translating the text into other languages could be a very powerful mechanism. The resulting service has indeed proven to be super useful as we have been able to do just this while versioning and saving the document with the translated text!

Natural Language Processing

The Natural Language Processing API exposes a few different operations that can be made to analyze text in very interesting ways. Not only can you extract particular information like people, places, or events, but sentiment and intent of text can also be derived. After having completed this integration, however, we were uncertain how to really use these derived results. We thought this would be the perfect opportunity to ask our readers in what way they think Natural Language Processing would be useful in the Nuxeo Platform!

Survey Question:

powered by Typeform