Language Translate

language/translate@1.0.2
Supported by 1 provider
D

Translate text usecase

Translate text to another language

Input
Text
Target language
Source language
Result
Text
Source language

1.Choose a provider

2.Use TranslateText with mock in your code

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('language/translate@1.0.2');

  // Use the profile
  const result = await profile
    .getUseCase('TranslateText')
    .perform({
      text: 'Enjoy your stay.',
      targetLanguage: 'ES'
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

text
targetLanguage
Language that specified text is translated into
sourceLanguage
Language of specified text

Example

{
  "text": "Enjoy your stay.",
  "targetLanguage": "ES"
}

Result (object)

text
sourceLanguage
Language of specified text

Example

{
  "text": "Disfrute de su estancia.",
  "sourceLanguage": "EN"
}

Implementation details

Provider
mock
Use case
TranslateText
Author
@superface
Source
Verified