Skip to content

RWS/languageweaver-sdk-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

languageweaver-sdk-samples

JavaScript SDK - Node.JS samples

Requirements

The JavaScript SDK samples require Node.js and npm to be installed.
We strongly recommend using a Node version manager like nvm to install Node.js and npm.
All other dependencies can be installed using the following command:

npm install

Configuration

You need to set up your API Credentials in order to run the samples. You can do this by creating a file named .env in the javascript directory and add your credentials:

LW_CLIENT_ID=your-client-id
LW_CLIENT_SECRET=your-client-secret

The credentials can also be defined directly in the command line.

LW_CLIENT_ID=your-client-id LW_CLIENT_SECRET=your-client-secret node path_to_sample // MacOS and Linux
set LW_CLIENT_ID=your-client-id&& set LW_CLIENT_SECRET=your-client-secret&& node path_to_sample // Windows

Running the Node.JS samples

Run the following command:

node path_to_sample

where path_to_sample is the relative path to the sample you want to run.
E.g.:

node samples/translations/text/TextTranslationService.js

JavaScript SDK - Browser samples

Requirements

The JavaScript SDK samples require Node.js and npm to be installed.
We strongly recommend using a Node version manager like nvm to install Node.js and npm.
All other dependencies can be installed using the following command:

npm install

Running the browser samples

Run the following command to start the React application:

npm start

Set your API credentials in the fields displayed at the top of the page.
Choose the code sample that you want to run.
The response will be available in the browser console.

Java SDK samples

Requirements

The Java SDK samples require a valid JDK setup as well as the maven dependency management tool to be installed.
The project dependencies can then be installed using the following command:

mvn clean compile

Configuration

You need to set up your API Credentials as environment variables in order to run the samples. These should be set according to your operating system.

LW_CLIENT_ID=your-client-id
LW_CLIENT_SECRET=your-client-secret

Running the Java samples

We advise using an IDE like Intellij IDEA in order to run the samples faster and more easily.
If you want to run the samples from the command line, the following commands should be used:

mvn clean compile
mvn exec:java -Dexec.mainClass=com.languageweaver.sdk.samples.dictionaries.CloudDictionaryService

where the desired sample to be run can be set using the -Dexec.mainClass property.

.Net SDK samples

Requirements

The .Net SDK samples require a valid .Net Runtime installation as well as the nuget package manager to be installed.
The project dependencies can then be installed using the following command:

nuget restore

Configuration

You need to set up your API Credentials in order to run the samples as environment variables.

LW_CLIENT_ID=your-client-id
LW_CLIENT_SECRET=your-client-secret

These can be set in the Properties/launchSettings.json file as follows:

"environmentVariables": {
    "LW_CLIENT_ID": "your-client-id",
    "LW_CLIENT_SECRET": "your-client-secret",
    "LW_EDGE_OVERWRITE_URL": "your-edge-overwrite-url",
    "LW_PRODUCT" : "CLOUD"
}

Running the .Net samples

Running the following command will execute the main class defined in the dotnet.csproj file, where the StartupObject property is specified:

dotnet run
<PropertyGroup>
        <StartupObject>LanguageWeaver.Sdk.Samples.Dictionaries.CloudDictionaryService</StartupObject>
</PropertyGroup>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors