Sample Translation Connector Implementation

You can use Content Toolkit to create the Sample Translation Connector, which provides a working connector that runs against a mock server.

You can use this sample implementation of a translation connector to help build your own custom translation connectors. The sample translation connector works with a mock Language Service Provider to simply add "##{locale}##" to each string to represent the "translation" of the string that an actual Language Service Provider would do.

The sample translation connector is built using the Connector Framework JS SDK provided by Oracle Content Management as part of Content Toolkit.

To install Content Toolkit, follow the directions listed on GitHub.

The following sections describe how to develop a sample translation connector:

  1. Create the Sample Translation Connector with Content Toolkit
  2. Register the Sample Translation Connector
  3. Test the Sample Translation Connector

Create the Sample Translation Connector with Content Toolkit

The create-translation-connector and start-translation-connector commands will create a named connector and install the required file to run the connector.

The connector contains a NodeJS server.js that you can use to run the Sample Translation Connector.

Register the Sample Translation Connector

Now that you've created the Sample Translation Connector, you can register it.

The registration of the connector can point to any Oracle Content Management server, such as the sample server:

> cec register-translation-connector connector1-auto -c connector1 -s 
http://localhost:8084/connector/rest/api -u admin -p <password> -f 
"BearerToken:Bearertoken1,WorkflowId:machine-workflow-id,AdditionalData:{}"

To register the translation connector through the Oracle Content Management Administration web interface:

  1. Sign in to your Oracle Content Management instance as an administrator or developer.
  2. Go to Administration > Integration > Translation Connectors and click Create.
  3. Enter the details to register your sample translation content connector.
    1. Name: Sample Connector – Machine Translation
    2. Description: Connector to translate OCE assets and sites
    3. Connector Service URL: http://host:port/sample-connector/rest/api (a URL tested previously)
  4. Click Next.
  5. Click the Additional Fields tab. Fill in the fields and Save before exiting the page.
    1. BearerToken: Bearer token1
    2. WorkflowId: machine-workflow-id
    3. Translation Job Editor: In the dropdown menu, find the name of Translation Job Editor that you've created and promoted.

      Note:

      This field is optional and will appear only if you have configured custom translation UI. For details, see REST Interfaces for Configuration and Authorization.
  6. Check Enable for end users on the General page. On the Integration page > Translation Connectors, the Enable buttom is also available to enable your sample connector.

The default timeout values for the translation connector are set in the following two properties:

ConnectorConnectionTimeout=20000
ConnectorReadTimeout=30000

If you want to change the values of these properties, you can add the properties to your config.cfg file and then modify either or both values.

Test the Sample Translation Connector

After you create and test a translation connector in Content Toolkit, you can register, enable, and test it in the Administration web interface.

Note:

Before you can test the translation connector in the Oracle Content Management UI, associate the connector with a repository. In the left panel, go to Content > Repositories, and select your repository. In the dropdown of Translation Connectors, select the connector that you’ve created. Save

To test the translation connector in the OCM UI:

  1. Sign in to Oracle Content Management as an Administrator or Developer.
  2. In the navigation menu for the Administration web interface, click Assets on the top left, and then click an asset to select it.
  3. Click Translate in the context menu.
  4. In the create dialog, choose < Sample Connector – Machine Translation > in the dropdown menu.
  5. Complete the create dialog.
  6. Navigate to the Translation Jobs page.

    When you view the translation job, it will now show you the % complete for the job.

  7. Refresh the page until it shows 100% complete.
  8. Import the translations from the connector.

    Upon successful import, your asset will be translated into your selected language or languages.

Content Toolkit also provides a framework to test your Sample Translation Connector. The Sample Translation Connector itself comes with a sample Oracle Content Management translation job file under data/translationBundle.zip, which you can use for testing.

To run your Sample Translation Connector, bring up the Content Toolkit develop pages, select the connector, and then click through each of the steps:

> cec develop &
> open http://localhost:8085/public/translationconnections.html

Select the Sample Translation Connector you registered, and it will lead you to a page that lists the following steps to test the connector:

  1. Get Server Config returns information about your connector that will be used to register the connector with Oracle Content Management.
  2. Create a job creates a unique ID for the job. The sample connector creates an out folder with the same name as the job ID in the connector.
  3. Send zipfile to job submits data/translationBundle.zip to the job for translation. The sample connector saves this file in the out/{jobid} folder, extracts the files, and then submits them for translation.
  4. Get the details of the job asks for the status of the job.
  5. Get the translated zip returns the created OCE Translation Job Translated Zip File, with the translation, once the job has moved to TRANSLATED.
  6. Delete the job removes the out/{jobid} folder.