New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

g11n-pipeline

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

g11n-pipeline

JavaScript (Node.js, etc) client for Bluemix Globalization Pipeline

  • 1.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Globalization Pipeline client

This is a JavaScript SDK for the Globalization Pipeline Bluemix service. The Globalization Pipeline service makes it easy for you to provide your global customers with Bluemix applications translated into the languages in which they work.

The SDK currently supports Node.js.

Node.js

The remainder of this document explains how to use the Globalization service with the Node.js client.

For a working Bluemix application sample, see gp-nodejs-sample.

npm version

Quickstart - Bluemix

Add g11n-pipeline to your project, as well as cfenv.

npm install --save g11n-pipeline cfenv

Load the gaas client object as follows (using cfenv ).

var appEnv = require('cfenv').getAppEnv();
var gpClient = require('g11n-pipeline').getClient({
   appEnv: appEnv
});

Using

To fetch the strings for a bundle named "hello", first create a bundle accessor:

var mybundle = gpClient.bundle('hello');

Then, call the getStrings function with a callback:

mybundle.getStrings({ languageId: 'es'}, function (err, result) {
    if (err) {
        // handle err..
        console.error(err);
    } else {
        var myStrings = result.resourceStrings;
        console.dir(myStrings);
    }
});

This code snippet will output the translated strings such as the following:

{
    hello:   '¡Hola!',
    goodbye: '¡Adiós!',
    …
}

Testing

See TESTING.md

API convention

APIs take a callback and use this general pattern:

gpClient.function( { /*params*/ } ,  function callback(err, ...))
  • params: an object containing input parameters, if needed.
  • err: if truthy, indicates an error has occured.
  • ...: other parameters (optional)

These APIs may be promisified easily using a library such as Q's nfcall:

return Q.ninvoke(bundle, "delete", {});
return Q.ninvoke(gpClient, "getBundleList", {});

Also, note that there are aliases from the swagger doc function names to the convenience name. For example, bundle.uploadResourceStrings can be used in place of bundle.uploadStrings.

All language identifiers are IETF BCP47 codes.

API reference

Author: Steven R. Loomis

g11n-pipeline.serviceRegex

a Regex for matching the service. Usage: var credentials = require('cfEnv') .getAppEnv().getServiceCreds(gp.serviceRegex);

Kind: static property of g11n-pipeline
Properties

Name
serviceRegex

g11n-pipeline.exampleCredentials

Example credentials

Kind: static property of g11n-pipeline
Properties

Name
exampleCredentials

g11n-pipeline~Client

Kind: inner class of g11n-pipeline

client.ping

Do we have access to the server?

Kind: instance property of Client

ParamTypeDescription
argsobject(ignored)
cbcallback

client.getBundleList(opts, cb)

Get a list of the bundles. Note: This function may be deprecated soon, but won't be removed.

Kind: instance method of Client

ParamTypeDescription
optsObject
opts.serviceInstanceStringoptional service instance
cbbundleListCallbackcallback: (err, array-of-ids)

client.supportedTranslations(args, cb)

This function returns a map from source language(s) to target language(s).

Kind: instance method of Client

ParamTypeDescription
argsobject
cbsupportedTranslationsCallback(err, map-of-languages)

client.getServiceInfo(args, cb)

Get information about this service

Kind: instance method of Client

ParamType
argsobject
cbbasicCallback

client.createUser(args, cb)

Create a user Note: This function may be deprecated soon, but won't be removed.

Kind: instance method of Client

ParamTypeDescription
argsobject
args.typestringUser type (ADMINISTRATOR, TRANSLATOR, or READER)
args.displayNamestringOptional display name for the user. This can be any string.
args.commentstringOptional comment
args.bundlesArrayset of accessible bundle ids or ['*'] to mean “all bundles”
args.metadataObjectoptional key/value pairs for user metadata
args.externalIdstringoptional external user ID for your application’s use
cbbasicCallback

client.deleteUser(args, cb)

Delete a user. Note: This function may be deprecated soon, but won't be removed.

Kind: instance method of Client

ParamTypeDescription
argsobjectTBD
args.userIdstringuser ID to be deleted.
cbbasicCallback

client.bundle(opts) ⇒ Bundle

Create a bundle access object. This doesn’t create the bundle itself, just a handle object. Call create() on the bundle to create it.

Kind: instance method of Client

ParamTypeDescription
optsObjectString (id) or map {id: bundleId, serviceInstance: serviceInstanceId}

g11n-pipeline~Bundle

Kind: inner class of g11n-pipeline

new Bundle(gp, props)
ParamTypeDescription
gpClientparent g11n-pipeline client object
propsObjectproperties to inherit

bundle.getInfoFields

List of fields usable with Bundle.getInfo()

Kind: instance property of Bundle

bundle.delete(opts, cb)

Delete this bundle.

Kind: instance method of Bundle

ParamType
optsObject
cbbasicCallback

bundle.create(body, cb)

Create this bundle.

Kind: instance method of Bundle

ParamTypeDescription
bodyObject-
body.sourceLanguagestringbcp47 id of source language such as 'en'
body.targetLanguagesArrayoptional array of target languages
body.metadataObjectoptional metadata for the bundle
body.partnerstringoptional ID of partner assigned to translate this bundle
cbbasicCallback

bundle.getInfo(opts, cb)

Get bundle info

Kind: instance method of Bundle

ParamTypeDescription
optsObjectOptions object
opts.fieldsStringComma separated list of fields
opts.translationStatusMetricsByLanguageBooleanOptional field (false by default)
opts.reviewStatusMetricsByLanguageBooleanOptional field (false by default)
opts.partnerStatusMetricsByLanguageBooleanOptional field (false by default)
cbbasicCallbackcallback (err, { updatedBy, updatedAt, sourceLanguage, targetLanguages, readOnly, metadata, partner} )

bundle.getStrings(opts, cb)

Fetch one entry's strings

Kind: instance method of Bundle

ParamTypeDescription
optsObjectoptions
opts.languageIdStringlanguage to fetch
opts.resourceKeyStringresource to fetch
cbbasicCallbackcallback (err, { resourceStrings: { strings … } })

bundle.getEntryInfo(opts, cb)

Fetch one entry's info Note: This function may be deprecated soon, but won't be removed.

Kind: instance method of Bundle

ParamTypeDescription
optsObjectoptions
opts.languageIdStringlanguage to fetch
opts.resourceKeyStringresource to fetch
cbbasicCallbackcallback (err, { resourceEntry: { updatedBy, updatedAt, value, sourceValue, reviewed, translationStatus, metadata, partnerStatus } } )

bundle.uploadStrings(opts, cb)

Upload resource strings, replacing all current contents for the language

Kind: instance method of Bundle

ParamTypeDescription
optsObjectoptions
opts.languageIdStringlanguage to update
opts.stringsObject.<string, string>strings to update
cbbasicCallback

bundle.update(opts, cb)

Kind: instance method of Bundle

ParamTypeDescription
optsObjectoptions
opts.targetLanguagesarrayoptional: list of target languages to update
opts.readOnlybooleanoptional: set this bundle to be readonly or not
opts.metadataobjectoptional: metadata to update
opts.partnerstringoptional: partner id to update
cbbasicCallbackcallback

bundle.updateStrings(opts, cb)

Update some strings in a language.

Kind: instance method of Bundle

ParamTypeDescription
optsObjectoptions
opts.stringsObject.<string, string>strings to update.
opts.resyncBooleanoptional: If true, resynchronize strings in the target language and resubmit previously-failing translation operations
cbbasicCallback

bundle.updateEntryInfo(opts, cb)

Note: This function may be deprecated soon, but won't be removed.

Kind: instance method of Bundle

ParamTypeDescription
optsObjectoptions
opts.valuestringstring value to update
opts.reviewedbooleanoptional boolean indicating if value was reviewed
opts.metadataobjectoptional metadata to update
opts.partnerStatusstringtranslation status maintained by partner
cbbasicCallback

g11n-pipeline~getClient(params) ⇒ Client

Construct a g11n-pipeline client. params.credentials is required unless params.appEnv is supplied.

Kind: inner method of g11n-pipeline

ParamTypeDescription
paramsObjectconfiguration params
params.appEnvObjectpass the result of cfEnv.getAppEnv(). Ignored if params.credentials is supplied.
params.credentialsObject.<string, string>Bound credentials as from the CF service broker (overrides appEnv)
params.credentials.urlstringservice URL. (should end in '/translate')
params.credentials.userIdstringservice API key.
params.credentials.passwordstringservice API key.
params.credentials.instanceIdstringinstance ID

docs autogenerated via jsdoc2md

Support

You can post questions about using this service in the developerWorks Answers site using the tag "[globalization-pipeline](https://developer.ibm.com/answers/topics/globalization-pipeline /)".

LICENSE

Apache 2.0. See LICENSE.txt

Copyright IBM Corp. 2015

Keywords

FAQs

Package last updated on 21 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc