npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@warren-bank/ibm-watson-language-translator

v1.1.0

Published

Unofficial Node.js client library and CLI for a subset of the IBM Watson Language Translator service API.

Downloads

2,196

Readme

ibm-watson-language-translator

Unofficial Node.js client library and CLI for a subset of the IBM Watson™ Language Translator service API.

Installation:

npm install @warren-bank/ibm-watson-language-translator

Library API:

  • translate(api_key, api_url, input_language_code, output_language_code, input_strings_array)
    • input parameters:
      • api_key
      • api_url
      • input_language_code
      • output_language_code
      • input_strings_array
        • type: array of strings
        • each string will be translated from input_language_code to output_language_code
        • the order of strings is preserved in the resolved return value
    • return value:
      • Promise that resolves to an array of translated strings in the same order as the input array

Supported Languages

| code | name | |---------|-----------------------| | "ar" | Arabic | | "eu" | Basque [1] | | "bn" | Bengali | | "bs" | Bosnian | | "bg" | Bulgarian | | "ca" | Catalan [1] | | "zh" | Chinese (Simplified) | | "zh-TW" | Chinese (Traditional) | | "hr" | Croatian | | "cs" | Czech | | "da" | Danish | | "nl" | Dutch | | "en" | English | | "et" | Estonian | | "fi" | Finnish | | "fr" | French | | "fr-CA" | French (Canadian) | | "de" | German | | "el" | Greek | | "gu" | Gujarati | | "he" | Hebrew | | "hi" | Hindi | | "hu" | Hungarian | | "ga" | Irish | | "id" | Indonesian | | "it" | Italian | | "ja" | Japanese | | "ko" | Korean | | "lv" | Latvian | | "lt" | Lithuanian | | "ms" | Malay | | "ml" | Malayalam | | "mt" | Maltese | | "cnr" | Montenegrin | | "ne" | Nepali | | "nb" | Norwegian Bokmål | | "pl" | Polish | | "pt" | Portuguese | | "ro" | Romanian | | "ru" | Russian | | "sr" | Serbian | | "si" | Sinhala | | "sk" | Slovak | | "sl" | Slovenian | | "es" | Spanish | | "sv" | Swedish | | "ta" | Tamil | | "te" | Telugu | | "th" | Thai | | "tr" | Turkish | | "uk" | Ukrainian | | "ur" | Urdu | | "vi" | Vietnamese | | "cy" | Welsh |

[1] Basque and Catalan are supported only for translation to and from Spanish.

related docs

Library Example:

const translate = require('@warren-bank/ibm-watson-language-translator')

{
  const print_translated_strings = async function(...args) {
    const translated_strings_array = await translate(...args)

    console.log(JSON.stringify(translated_strings_array, null, 2))
  }

  const api_key              = 'xxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxx'
  const api_url              = 'https://api.us-south.language-translator.watson.cloud.ibm.com/instances/yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy'
  const input_language_code  = 'en'
  const output_language_code = 'de'
  const input_strings_array  = ['Hello world', 'Welcome to the jungle']

  print_translated_strings(api_key, api_url, input_language_code, output_language_code, input_strings_array)
}

CLI Usage:

ibm-translate <options>

options:
========
"-h"
"--help"
    Print a help message describing all command-line options.

"-v"
"--version"
    Display the version.

"-k" <key>
"--api-key" <key>
    [optional] IBM Cloud account API key.
    Default: Value is read from "IBM_TRANSLATOR_API_KEY" environment variable.

"-u" <url>
"--api-url" <url>
    [optional] IBM Cloud account API URL.
    Default: Value is read from "IBM_TRANSLATOR_API_URL" environment variable.

"-i" <language>
"--input-language" <language>
    [required] Language code for input string.

"-o" <language>
"--output-language" <language>
    [required] Language code for translated output string, written to stdout.

"-s" <text>
"--input-string" <text>
    [required] Input string to be translated.

language codes:
===============
  "ar"    Arabic
  "eu"    Basque [1]
  "bn"    Bengali
  "bs"    Bosnian
  "bg"    Bulgarian
  "ca"    Catalan [1]
  "zh"    Chinese (Simplified)
  "zh-TW" Chinese (Traditional)
  "hr"    Croatian
  "cs"    Czech
  "da"    Danish
  "nl"    Dutch
  "en"    English
  "et"    Estonian
  "fi"    Finnish
  "fr"    French
  "fr-CA" French (Canadian)
  "de"    German
  "el"    Greek
  "gu"    Gujarati
  "he"    Hebrew
  "hi"    Hindi
  "hu"    Hungarian
  "ga"    Irish
  "id"    Indonesian
  "it"    Italian
  "ja"    Japanese
  "ko"    Korean
  "lv"    Latvian
  "lt"    Lithuanian
  "ms"    Malay
  "ml"    Malayalam
  "mt"    Maltese
  "cnr"   Montenegrin
  "ne"    Nepali
  "nb"    Norwegian Bokmål
  "pl"    Polish
  "pt"    Portuguese
  "ro"    Romanian
  "ru"    Russian
  "sr"    Serbian
  "si"    Sinhala
  "sk"    Slovak
  "sl"    Slovenian
  "es"    Spanish
  "sv"    Swedish
  "ta"    Tamil
  "te"    Telugu
  "th"    Thai
  "tr"    Turkish
  "uk"    Ukrainian
  "ur"    Urdu
  "vi"    Vietnamese
  "cy"    Welsh

[1] Basque and Catalan are supported only for translation to and from Spanish.

CLI Example:

source ~/IBM_TRANSLATOR_API_CREDENTIALS.sh

ibm-translate -i 'en' -o 'de' -s 'Hello world'
ibm-translate -i 'en' -o 'de' -s 'Welcome to the jungle'

Legal: