Skip to content

michelle-miller/language-translator-nodejs

 
 

Repository files navigation

Language Translator Node.js Build Status

The IBM Watson™ Language Translator service provides an Application Programming Interface (API) that lets you identify the language of text, and then use a custom business domain to translate the text from one supported language to another.
You can translate either by letting the service identify the source language or by selecting a source language and then by selecting a target language, and a business domain. Domain translation is linguistically targeted these business domains:

  • The News domain - targeted at news articles and transcripts, it translates English to and from Arabic, Brazilian Portuguese, French, Italian, or Spanish. It also translates Spanish to and from French.
  • The Conversational domain - targeted at conversational colloquialisms, it translates English to and from Arabic, Brazilian Portuguese, French, Italian, or Spanish.
  • The Patent domain - targeted at technical and legal terminology, it translates Brazilian Portuguese, Chinese, or Spanish to English.

Give it a try! Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on Bluemix.

Deploy to Bluemix

Getting started

  1. You need a Bluemix account. If you don't have one, sign up. Experimental Watson Services are free to use.

  2. Download and install the Cloud-foundry CLI tool if you haven't already.

  3. Edit the manifest.yml file and change <application-name> to something unique. The name you use determines the URL of your application. For example, <application-name>.mybluemix.net.

    applications:
    - services:
      - language-translator-service
      name: <application-name>
      command: node app.js
      path: .
      memory: 128M
    
  4. Connect to Bluemix with the command line tool.

    $ cf api https://api.ng.bluemix.net
    $ cf login -u <your user ID>
  5. Create the Language Translator service in Bluemix.

    $ cf create-service language_translator standard language-translator-service
  6. Push your app to make it live:

    $ cf push

For more details about developing applications that use Watson Developer Cloud services in Bluemix, see Getting started with Watson Developer Cloud and Bluemix.

Running locally

  1. Download and install Node.js and npm.

  2. Configure the code to connect to your service:

    1. Copy the credentials from your language-translator-service service in Bluemix. Run the following command:

      $ cf env <application-name>

      Example output:

      System-Provided:
      {
        "VCAP_SERVICES": {
          "language_translator": [
            {
              "credentials": {
                "password": "<password>",
                "url": "<url>",
                "username": "<username>"
              }
              "label": "language-translator",
              "name": "language-translator-service",
              "plan": "standard",
              "tags": [
                ...
              ]
            }
          ]
        }
      }
    2. Copy username, password, and url from the credentials.

    3. Open the app.js file and paste the username, password, and url credentials for the service.

    4. Save the creds.js file.

  3. Install the Language Translator Node.js package:

    1. Change to the new directory that contains the project.
    2. Run the following command:
    $ npm install
  4. Run the following command to start the application:

    node app.js
  5. Point your browser to http://localhost:3000.

Troubleshooting

  • The main source of troubleshooting and recovery information is the Bluemix log. To view the log, run the following command:

    $ cf logs <application-name> --recent
  • For more details about the service, see the documentation for the Language Translator.

License

This sample code is licensed under Apache 2.0. Full license text is available in LICENSE.
This sample code is using jQuery which is licensed under MIT.
This sample code is using bootstrap which is licensed under MIT.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page

About

Sample Node.js Application for the IBM Language Translation Service

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 77.2%
  • JavaScript 14.5%
  • HTML 8.3%