Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

azure-translator-code

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azure-translator-code

Azure Cognitive Services Translator Text API Code for Use with Common Languages

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-28.12%
Maintainers
2
Weekly downloads
 
Created
Source

Azure Translator Code

The Azure Translator Code library is a powerful tool for translating JSON files into multiple languages using the Azure Cognitive Translator service. This library supports translation of JSON files in multiple folders or within a single folder, depending on your needs.

npm version License: MIT npm downloads

Buy Me A Coffee

Installation

To get started, you can install the library via npm:

As devDependencies

npm install -D azure-translator-code

or

As dependencies

npm install azure-translator-code

You also can use yarn

yarn add install azure-translator-code

Usage

You can import the JSON file you want to translate in two different ways:

Importing a JSON File

const jsonFile = require('./jsonFileToTranslate/en.json');

// or

// IMPORTANT
// The file must follow this structure.
const jsonFile = {
  "translation": {
    "welcome": "Welcome",
    "hello": "Hello",
  }
};

Now, you can use the library to translate the JSON file into multiple languages:

const { translateToMultipleFolders, translateToUnicFolder } = require('azure-translator-code');

// or

import { translateToMultipleFolders, translateToUnicFolder } from 'azure-translator-code';

const key = 'sds12312a213aaaa9b2d0c37eds37b'; // REPLACE WITH YOUR OWN KEY HERE
const endpoint = 'https://api.cognitive.microsofttranslator.com/';
const location = 'eastus';
const fromLang = 'en';
const toLangs = [
  'pt',
  'de',
  'es',
  'fr',
  'it',
  'ja',
  'ko',
  'nl',
  'ru',
  'zh',
  'pt-pt',
  'ar',
  'tlh-Latn',
];

const jsonFile = {
  "translation": {
    "welcome": "Welcome",
    "hello": "Hello",
  }
};

// Translation to multiple folders
translateToMultipleFolders(key, endpoint, location, fromLang, toLangs, jsonFile);
// This function will return a folder called folder multiFolderGeneratedTranslations



// Translation to a single folder
translateToUnicFolder(key, endpoint, location, fromLang, toLangs, jsonFile);
// This function will return a folder called folder unicFolderGeneratedTranslations

Make sure to replace the key and endpoint information with your own Azure access credentials. Ensure that the JSON file and settings are correctly defined according to your needs.

Contributing If you wish to contribute to this project, feel free to open an issue or submit a pull request on our GitHub repository.

Buy Me A Coffee

Keywords

FAQs

Package last updated on 16 Sep 2023

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