If you want to offer translation on-the-fly, whether it's as short as a chat messages or long as a news article, and deliver it to any number of subscribers, in realtime, PubNub Functions lets you do it.
Select from a list of prebuilt Functions, or build an integration with a service of your choice. Here are a few suggestions:
- IBM Watson Language Translator provides an API for translating and publishing text for 11 different languages.
- Amazon Translate removes the complexity of building translation capabilities into your applications with a simple API call. This makes it easy to localize an application, or process multilingual data within your existing workflows.
- Microsoft Translator is a cognitive services offering from Microsoft Cloud and Enterprise division. It provides a scalable, compliant, and customizable neural machine translation cloud service that supports over 60 languages.
IBM Watson Language Translator Tutorial
IBM Watson Language Translator function allows you to translate text, whether it's as short as a chat messages or long as a news article, and deliver it to any number of subscribers, in realtime.
Language Translator from IBM Watson provides an API for translating and publishing text for 11 different languages.
Getting started with the Watson APIs
First, you’ll need to get started with a Bluemix account to take advantage of the Watson APIs.
Sign up with the Bluemix signup form.
Open the IBM Watson Language Translator API page, and add it to your service dashboard.
On the service credentials pane of your new service instance, make a note of the username and password.
Setting up the PubNub Function
Next, set up a PubNub Function to get your code running on the network.
Click Try it Now on the IBM Watson Language Translator function page to import the code directly into a new or existing app.
Set the event type to
Before Publish or Fire, and specify a channel to trigger the function. You can use wildcards (such as
chat.*) to trigger the function on multiple channels.
passwordconstants with your Watson credentials from the last Watson setup step above.
langsarray with the languages you want to use, and click the red Save button.
Click Start Module to start the Function, and test it using the Publish button and payload on the left.
For a more detailed overview of writing a function, refer to these instructions on the Functions Overview page.
This function enables communication between multiple participants in their native languages. It supports English, French, and Spanish, but you can support additional languages by adding them to the
A message is sent to the input channel. Then it is translated using IBM Watson API while the message is in transit. The published message is appended with a translation before it reaches subscribers.
Input: Publish a message text on the input channel.
Output (Spanish): The text is translated and added to the message payload.