Skip to main content
skill

azure-ai-translation-ts — Claude Code skill: TypeScript translation

This skill helps build TypeScript apps with Azure translation SDKs for text and documents. Use it when adding language detection, transliteration, or batch document translation.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add microsoft/skills --skill azure-ai-translation-ts -a claude-code
Open on GitHub

What azure-ai-translation-ts does

The skill guides Claude Code through the REST clients @azure-rest/ai-translation-text and @azure-rest/ai-translation-document. The text client covers translations to multiple target languages, translation options, supported-language lookup, transliteration, and language detection. It also shows how to check API responses.

For a single document, the example sends a file and writes the translated response. Batch jobs use Azure Blob Storage containers with SAS URLs, and the skill shows how to retrieve the operation status and list documents. Install the relevant SDK package and @azure/identity; the text client example uses a subscription key and region, while document translation can use an Azure credential or an API key. Batch translation depends on SAS URLs for both source and target containers.

What it helps with

  • translate text into multiple target languages
  • detect the language of an input string
  • transliterate text between writing systems
  • translate a document or start a batch job

Example prompts for the agent

  • Add Azure text translation to my TypeScript app and translate the input into Spanish and French.
  • Use Azure to detect the language of this input string.
  • Set up batch document translation with Azure Blob Storage and show me the operation status.

How to install azure-ai-translation-ts

1Skills CLI (Vercel)

npx skills add microsoft/skills --skill azure-ai-translation-ts -a claude-code

2Manually: put the files in place

~/.claude/skills/azure-ai-translation-ts/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/azure-ai-translation-ts/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about azure-ai-translation-ts

How do I install azure-ai-translation-ts in Claude Code?

Run npx skills add microsoft/skills --skill azure-ai-translation-ts -a claude-code. The skill file is at ~/.claude/skills/azure-ai-translation-ts/SKILL.md.

What does azure-ai-translation-ts do?

It guides TypeScript development with Azure SDKs for text and document translation, language detection, and transliteration.

What does batch document translation require?

The example uses Azure Blob Storage and SAS URLs for the source and destination containers. It also shows how to fetch the job status.

Source text

SKILL.md · MIT
---
name: azure-ai-translation-ts
description: Build translation applications using Azure Translation SDKs for JavaScript (@azure-rest/ai-translation-text, @azure-rest/ai-translation-document). Use when implementing text translation, transliteration, language detection, or batch document translation.
license: MIT
metadata:
  author: Microsoft
  version: "1.0.0"
  package: '@azure-rest/ai-translation-text, @azure-rest/ai-translation-document'
---

# Azure Translation SDKs for TypeScript

Text and document translation with REST-style clients.

## Installation

```bash
# Text translation
npm install @azure-rest/ai-translation-text @azure/identity

# Document translation
npm install @azure-rest/ai-translation-document @azure/identity
```

## Environment Variables

```bash
TRANSLATOR_ENDPOINT=https://api.cognitive.microsofttranslator.com
TRANSLATOR_SUBSCRIPTION_KEY=<your-api-key>
TRANSLATOR_REGION=<your-region>  # e.g., westus, eastus
AZURE_TOKEN_CREDENTIALS=prod # Required only if DefaultAzureCredential is used in production
```

## Text Translation Client

### Authentication

```typescript
import TextTranslationClient, { TranslatorCredential } from "@azure-rest/ai-translation-text";

// API Key + Region
const credential: TranslatorCredential = {
  key: process.env.TRANSLATOR_SUBSCRIPTION_KEY!,
  region: process.env.TRANSLATOR_REGION!,
};
const client = TextTranslationClient(process.env.TRANSLATOR_ENDPOINT!, credential);

// Or just credential (uses global endpoint)
const client2 = TextTranslationClient(credential);
```

### Translate Text

```typescript
import TextTranslationClient, { isUnexpected } from "@azure-rest/ai-translation-text";

const response = await client.path("/translate").post({
  body: {
    inputs: [
      {
        text: "Hello, how are you?",
        language: "en",  // source (optional, auto-detect)
        targets: [
          { language: "es" },
          { language: "fr" },
        ],
      },
    ],
  },
});

if (isUnexpected(response)) {
  throw response.body.error;
}

for (const result of response.body.value) {
  for (const translation of result.translations) {
    console.log(`${translation.language}: ${translation.text}`);
  }
}
```

### Translate with Options

```typescript
const response = await client.path("/translate").post({
  body: {
    inputs: [
      {
        text: "Hello world",
        language: "en",
        textType: "Plain",  // or "Html"
        targets: [
          {
            language: "de",
            profanityAction: "NoAction",  // "Marked" | "Deleted"
            tone: "formal",  // LLM-specific
          },
        ],
      },
    ],
  },
});
```

### Get Supported Languages

```typescript
const response = await client.path("/languages").get();

if (isUnexpected(response)) {
  throw response.body.error;
}

// Translation languages
for (const [code, lang] of Object.entries(response.body.translation || {})) {
  console.log(`${code}: ${lang.name} (${lang.nativeName})`);
}
```

### Transliterate

```typescript
const response = await client.path("/transliterate").post({
  body: { inputs: [{ text: "这是个测试" }] },
  queryParameters: {
    language: "zh-Hans",
    fromScript: "Hans",
    toScript: "Latn",
  },
});

if (!isUnexpected(response)) {
  for (const t of response.body.value) {
    console.log(`${t.script}: ${t.text}`);  // Latn: zhè shì gè cè shì
  }
}
```

### Detect Language

```typescript
const response = await client.path("/detect").post({
  body: { inputs: [{ text: "Bonjour le monde" }] },
});

if (!isUnexpected(response)) {
  for (const result of response.body.value) {
    console.log(`Language: ${result.language}, Score: ${result.score}`);
  }
}
```

## Document Translation Client

### Authentication

```typescript
import DocumentTranslationClient from "@azure-rest/ai-translation-document";
import { DefaultAzureCredential, ManagedIdentityCredential } from "@azure/identity";

const endpoint = "https://<translator>.cognitiveservices.azure.com";

// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
const credential = new DefaultAzureCredential({requiredEnvVars: ["AZURE_TOKEN_CREDENTIALS"]});
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/javascript/api/overview/azure/identity-readme?view=azure-node-latest#credential-classes
// const credential = new ManagedIdentityCredential();

// TokenCredential
const client = DocumentTranslationClient(endpoint, credential);

// API Key
const client2 = DocumentTranslationClient(endpoint, { key: "<api-key>" });
```

### Single Document Translation

```typescript
import DocumentTranslationClient from "@azure-rest/ai-translation-document";
import { writeFile } from "node:fs/promises";

const response = await client.path("/document:translate").post({
  queryParameters: {
    targetLanguage: "es",
    sourceLanguage: "en",  // optional
  },
  contentType: "multipart/form-data",
  body: [
    {
      name: "document",
      body: "Hello, this is a test document.",
      filename: "test.txt",
      contentType: "text/plain",
    },
  ],
}).asNodeStream();

if (response.status === "200") {
  await writeFile("translated.txt", response.body);
}
```

### Batch Document Translation

```typescript
import { ContainerSASPermissions, BlobServiceClient } from "@azure/storage-blob";

// Generate SAS URLs for source and target containers
const sourceSas = await sourceContainer.generateSasUrl({
  permissions: ContainerSASPermissions.parse("rl"),
  expiresOn: new Date(Date.now() + 24 * 60 * 60 * 1000),
});

const targetSas = await targetContainer.generateSasUrl({
  permissions: ContainerSASPermissions.parse("rwl"),
  expiresOn: new Date(Date.now() + 24 * 60 * 60 * 1000),
});

// Start batch translation
const response = await client.path("/document/batches").post({
  body: {
    inputs: [
      {
        source: { sourceUrl: sourceSas },
        targets: [
          { targetUrl: targetSas, language: "fr" },
        ],
      },
    ],
  },
});

// Get operation ID from header
const operationId = new URL(response.headers["operation-location"])
  .pathname.split("/").pop();
```

### Get Translation Status

```typescript
import { isUnexpected, paginate } from "@azure-rest/ai-translation-document";

const statusResponse = await client.path("/document/batches/{id}", operationId).get();

if (!isUnexpected(statusResponse)) {
  const status = statusResponse.body;
  console.log(`Status: ${status.status}`);
  console.log(`Total: ${status.summary.total}`);
  console.log(`Success: ${status.summary.success}`);
}

// List documents with pagination
const docsResponse = await client.path("/document/batches/{id}/documents", operationId).get();
const documents = paginate(client, docsResponse);

for await (const doc of documents) {
  console.log(`${doc.id}: ${doc.status}`);
}
```

### Get Supported Formats

```typescript
const response = await client.path("/document/formats").get();

if (!isUnexpected(response)) {
  for (const format of response.body.value) {
    console.log(`${format.format}: ${format.fileExtensions.join(", ")}`);
  }
}
```

## Key Types

```typescript
// Text Translation
import type {
  TranslatorCredential,
  TranslatorTokenCredential,
} from "@azure-rest/ai-translation-text";

// Document Translation
import type {
  DocumentTranslateParameters,
  StartTranslationDetails,
  TranslationStatus,
} from "@azure-rest/ai-translation-document";
```

## Best Practices

1. **Auto-detect source** - Omit `language` parameter to auto-detect
2. **Batch requests** - Translate multiple texts in one call for efficiency
3. **Use SAS tokens** - For document translation, use time-limited SAS URLs
4. **Handle errors** - Always check `isUnexpected(response)` before accessing body
5. **Regional endpoints** - Use regional endpoints for lower latency

© Microsoft · MIT · microsoft/skills

Similar skills

All skills for Cloud: AWS, Azure, GCP →

From the same set242

The whole set →
azure-eventhub-ts Guides AI coding assistants on streaming events with Azure Event Hubs and TypeScript. Handy for ingesting IoT telemetry and processing partitioned real-time streams. 1installs azure-cosmos-ts A skill covering the Azure Cosmos DB JavaScript/TypeScript SDK: document CRUD, queries, bulk operations. Useful when the agent writes data-access code. 1installs azure-appconfiguration-ts A skill that gets your agent writing TypeScript against Azure App Configuration: settings, feature flags, Key Vault references and dynamic refresh. 1installs azure-ai-voicelive-ts Guides speech assistant development with the Azure AI Voice Live JavaScript and TypeScript SDK over bidirectional WebSockets. Useful for Node.js and browser real-time voice apps. 1installs azure-ai-projects-ts Tells your coding agent how to use the Azure AI Projects SDK for JavaScript: agents, connections, deployments, datasets, indexes and evaluations. 1installs azure-ai-document-intelligence-ts Guides code generation for Azure Document Intelligence REST SDK in TypeScript. Useful for extracting text, tables, invoices, and receipts using prebuilt or custom models. 1installs azure-ai-contentsafety-ts Use this skill to add Azure AI Content Safety checks to TypeScript projects, including text and image analysis and custom blocked-term lists. 1installs m365-agents-py Builds Teams, Microsoft 365, and Copilot Studio agents in Python using the official Agents SDK. Generates aiohttp server setup, AgentApplication routing, and MSAL authentication. 1installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor