Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
This is a JavaScript client and sample code for the IBM Globalization Bluemix service. The IBM Globalization service makes it easy for you to provide your global customers with Bluemix applications translated into the languages in which they work.
Using the client code in this project, either from node.js, or from any browser using the jQuery sample code, your application can dynamically request translations of your application content from the IBM Globalization service.
There is an experimental sample showing use of the use in the jquery-sample
directory.
See the Readme in that directory for more details.
The rest of this document explains how to use the Globalization service with the node.js client.
For a working Bluemix application sample, see gaas-nodejs-hello.
Add gaas
to your project, as well as cfenv
.
npm install --save gaas cfenv
Load the gaas client object as follows (using cfenv ).
Note that /IBM Globalization.*/
will match any service named with something starting
with IBM Globalization
(the default).
var appEnv = require('cfenv').getAppEnv();
var gaasClient = require('gaas').getClient({
credentials: appEnv.getService(/IBM Globalization.*/).credentials
});
Or, if you are providing credentials manually:
var gaasClient = require('gaas').getClient({
credentials: {
uri: 'https://<GaaS server URL>',
api_key: '<your API key>'
}
});
Note that api_key
can be from the bound service credentials, or else a "reader key" as
visible in the IBM Globalization service dashboard.
To load the key "hello" in Spanish from the project named "world" you can use this code:
var myProject = gaasClient.project('world');
myProject.getResourceEntry({
resKey: 'hello',
languageID: 'es'
},
function(err, entry) {
if(err) {
console.error(err); return;
} else if(entry.value) {
console.log( entry.value ); // Print out the value!
} else {
console.error('Status is ' + entry.translationStatus); // may be: 'inProgress' or 'failed'
}
});
APIs which take a callback use this pattern:
obj.function( { /*params*/ } , function callback(err, ...))
err
: if truthy, indicates an error has occured....
: other parameters (optionally)All language identifiers are IETF BCP47 codes.
#gaas
Author: Steven R. Loomis
Members
##callback: gaas~basicCallback Params
object
- if(err), errorobject
- any result dataScope: inner typedef of gaas
Type: function
##callback: gaas~supportedTranslationsCallback
Params
object
- if(err), errorObject.<string, Array.<string>>
- source : [target...] languagesScope: inner typedef of gaas
Type: function
##callback: gaas~projectInfoCallback
Params
object
- if(err), errorProject
- the updated Project object with the latest dataScope: inner typedef of gaas
Type: function
##callback: gaas~resourceCallback
Params
object
- if(err), errorResourceData
- the specified resource data
Object.<string, string>
- the translated key/value pairsArray.<string>
- a list of the keys that are still in progressArray.<string>
- a list of the keys that failed to translateScope: inner typedef of gaas
Type: function
##callback: gaas~resourceCallback
Params
object
- if(err), errorResourceEntry
- the specified resource entry
string
- the entry's string valuestring
- the entry's translation statusScope: inner typedef of gaas
Type: function
##callback: gaas~listCallback
Params
object
- if(err), errorObject.<string, Project>
- map from project ID to project objectScope: inner typedef of gaas
Type: function
##class: gaas~Client
Members
###client.supportedTranslations(args, cb) This function returns a map from source language(s) to target language(s).
Params
object
supportedTranslationsCallback
###client.ping(args, cb) Do we have access to the server?
Params
object
- (ignored)callback
###client.project(projectID, props) Create a new Project object for further access. Note that this function doesn't create the project or fetch any information.
Params
string
object
- optional properties to set on the object###client.listProjects(args) List the projects available
Params
object
- currently not used##class: gaas~ResourceData Members
##class: gaas~ResourceEntry Members
###project.create(args, cb) Create the project
Params
object
- parameters for creation
string
- BCP47 langauge tag of translation sourceArray.<string>
- optional array of BCP47 language tags for translation targetbasicCallback
###project.remove(args, cb) Remove the project
Params
object
- (ignored)basicCallback
###project.getInfo() Fetch project information. The callback is given a new Project object with updated information.
###project.addTargetLanguages(args, cb) Add target languages to the project
Params
object
Array.<string>
- array of 1 or more languages to addbasicCallback
###project.getResourceData(args, cb) Get resourcedata for one language
Params
object
string
- which BCP47 language to get info forresourceCallback
###project.updateResourceData(args, cb) Update resource data and/or retry translation
Params
object
string
- language to update (source or target)object
boolean
- if true, replace ALL resource keys instead of just appendingboolean
- if true, retry translationObject.<string, string>
- key/value pairs to updatebasicCallback
###project.deleteLanguage(args, cb) Delete a target language from the project. (Source languages cannot be deleted)
Params
object
string
- BCP47 id of language to deletebasicCallback
###project.getResourceEntry(args, cb) Get a single ResourceEntry
Params
object
string
- langauge name to fetchstring
- key name to fetchentryCallback
docs autogenerated via jsdoc2md
You can post questions about using this service in the developerWorks Answers site using the tag "Globalization".
Apache 2.0. See LICENSE.txt
FAQs
JavaScript (Node.js, etc) client for Globalization-as-a-Service
We found that gaas demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.