{"_id":"translateplus-js","_rev":"2-37c30ec9d7e37c86187cec4e1cabcf4f","name":"translateplus-js","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.0":{"name":"translateplus-js","version":"2.0.0","keywords":["translation","api","translate","multilingual","i18n","localization","translateplus","translation-api"],"author":{"name":"TranslatePlus","email":"support@translateplus.io"},"license":"MIT","_id":"translateplus-js@2.0.0","maintainers":[{"name":"translateplus","email":"support@translateplus.io"}],"homepage":"https://translateplus.io","bugs":{"url":"https://github.com/translateplus/translateplus-js/issues"},"dist":{"shasum":"c5d8c45a424f09710b3735b6b8393f2d248af93e","tarball":"https://registry.npmjs.org/translateplus-js/-/translateplus-js-2.0.0.tgz","fileCount":9,"integrity":"sha512-YCv9O/QIKVx67EuXxbltZO9l4jBbweZk2tk3YFT9lTEBZyl27mgcCbGxHp34mMEaCP2IfJKgV3gnP7/OPSRPNA==","signatures":[{"sig":"MEYCIQCC3uRvp7kvm/awzT0hnRgEj/93kjsvMPkknjHEYedKewIhAO+mB2sXz8damZQo+0XJaIwtTg3ptPngjtUc4TjIYPDe","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":123028},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.esm.js","browser":{"node-fetch":false},"engines":{"node":">=14.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.js","require":"./dist/index.js"}},"gitHead":"5ed09332eb4c6cbdc97a4037ba087486a9f95771","scripts":{"dev":"tsup --watch","lint":"eslint src --ext .ts","test":"jest","build":"tsup","format":"prettier --write \"src/**/*.ts\"","test:watch":"jest --watch","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"translateplus","email":"support@translateplus.io"},"repository":{"url":"git+https://github.com/translateplus/translateplus-js.git","type":"git"},"_npmVersion":"10.8.2","description":"Official JavaScript/TypeScript client library for TranslatePlus API - Professional translation service for text, HTML, emails, subtitles, and i18n files in 100+ languages","directories":{},"_nodeVersion":"20.19.6","dependencies":{"form-data":"^4.0.0","node-fetch":"^2.7.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","tsup":"^7.2.0","eslint":"^8.45.0","ts-jest":"^29.1.0","prettier":"^3.0.0","typescript":"^5.1.0","@types/jest":"^29.5.0","@types/node":"^20.0.0","@types/node-fetch":"^2.6.9","@typescript-eslint/parser":"^6.0.0","@typescript-eslint/eslint-plugin":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/translateplus-js_2.0.0_1768166323399_0.9198552891459975","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"name":"translateplus-js","version":"2.0.1","description":"Official JavaScript/TypeScript client library for TranslatePlus API - Professional translation service for text, HTML, emails, subtitles, and i18n files in 100+ languages","main":"dist/index.js","module":"dist/index.esm.js","types":"dist/index.d.ts","scripts":{"build":"tsup","dev":"tsup --watch","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","lint":"eslint src --ext .ts","format":"prettier --write \"src/**/*.ts\"","prepublishOnly":"npm run build"},"keywords":["translation","api","translate","multilingual","i18n","localization","translateplus","translation-api"],"author":{"name":"TranslatePlus","email":"support@translateplus.io"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/translateplus/translateplus-js.git"},"bugs":{"url":"https://github.com/translateplus/translateplus-js/issues"},"homepage":"https://translateplus.io","engines":{"node":">=14.0.0"},"browser":{"node-fetch":false},"dependencies":{"form-data":"^4.0.0","node-fetch":"^2.7.0"},"devDependencies":{"@types/jest":"^29.5.0","@types/node":"^20.0.0","@types/node-fetch":"^2.6.9","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","eslint":"^8.45.0","jest":"^29.5.0","prettier":"^3.0.0","ts-jest":"^29.1.0","tsup":"^7.2.0","typescript":"^5.1.0"},"exports":{".":{"import":"./dist/index.esm.js","require":"./dist/index.js","types":"./dist/index.d.ts"}},"_id":"translateplus-js@2.0.1","gitHead":"d7706bd50f3d352e4c324f14f018abb2e65f941c","_nodeVersion":"20.19.6","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Ld2gZsouMtOqHc2O5y7M1AWaSjLNQThoC8sMuG30G5TbrotxwTdUYMsWduZWPewQaI4JdanWMvXh04G0yt++6w==","shasum":"50291d004c70d5c9fa9791ef9822d288ba06a670","tarball":"https://registry.npmjs.org/translateplus-js/-/translateplus-js-2.0.1.tgz","fileCount":9,"unpackedSize":123030,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/translateplus-js@2.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEmtYgF8Id8rGcl6UKwsjWKBPJflmQXzJajWQipAyDyqAiBYtHQnIPgf9GsY5AK91/VXyeDsq37qwufhZ5swCZx1uw=="}]},"_npmUser":{"name":"translateplus","email":"support@translateplus.io"},"directories":{},"maintainers":[{"name":"translateplus","email":"support@translateplus.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/translateplus-js_2.0.1_1768168860702_0.19205327123051252"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-11T21:18:43.338Z","modified":"2026-01-11T22:01:01.262Z","2.0.0":"2026-01-11T21:18:43.557Z","2.0.1":"2026-01-11T22:01:00.868Z"},"bugs":{"url":"https://github.com/translateplus/translateplus-js/issues"},"author":{"name":"TranslatePlus","email":"support@translateplus.io"},"license":"MIT","homepage":"https://translateplus.io","keywords":["translation","api","translate","multilingual","i18n","localization","translateplus","translation-api"],"repository":{"type":"git","url":"git+https://github.com/translateplus/translateplus-js.git"},"description":"Official JavaScript/TypeScript client library for TranslatePlus API - Professional translation service for text, HTML, emails, subtitles, and i18n files in 100+ languages","maintainers":[{"name":"translateplus","email":"support@translateplus.io"}],"readme":"# TranslatePlus JavaScript/TypeScript Client\n\n[![npm version](https://badge.fury.io/js/translateplus-js.svg)](https://badge.fury.io/js/translateplus-js)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.1+-blue.svg)](https://www.typescriptlang.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-14+-green.svg)](https://nodejs.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nOfficial JavaScript/TypeScript client library for [Translation API](https://translateplus.io) - Professional translation service for text, HTML, emails, subtitles, and i18n files in 100+ languages.\n\n## Features\n\n- ✅ **TypeScript Support** - Full type definitions included\n- ✅ **All Endpoints Supported** - Text, batch, HTML, email, subtitles, and i18n translation\n- ✅ **Concurrent Requests** - Built-in support for parallel translations\n- ✅ **Error Handling** - Comprehensive exception handling with detailed error messages\n- ✅ **Production Ready** - Retry logic, rate limiting, and connection pooling\n- ✅ **100+ Languages** - Support for all languages available in TranslatePlus\n- ✅ **ESM & CommonJS** - Works with both import and require\n\n## Installation\n\n```bash\nnpm install translateplus-js\n```\n\nor with yarn:\n\n```bash\nyarn add translateplus-js\n```\n\nor with pnpm:\n\n```bash\npnpm add translateplus-js\n```\n\n## Quick Start\n\n### TypeScript/ES Modules\n\n```typescript\nimport { TranslatePlusClient } from 'translateplus-js';\n\n// Initialize client\nconst client = new TranslatePlusClient({\n  apiKey: 'your-api-key'\n});\n\n// Translate a single text\nconst result = await client.translate({\n  text: 'Hello, world!',\n  source: 'en',\n  target: 'fr'\n});\nconsole.log(result.translations.translation);\n// Output: \"Bonjour le monde !\"\n\n// Translate multiple texts\nconst texts = ['Hello', 'Goodbye', 'Thank you'];\nconst batchResult = await client.translateBatch({\n  texts,\n  source: 'en',\n  target: 'fr'\n});\nbatchResult.translations.forEach(t => console.log(t.translation));\n\n// Translate HTML\nconst html = '<p>Hello <b>world</b></p>';\nconst htmlResult = await client.translateHTML({\n  html,\n  source: 'en',\n  target: 'fr'\n});\nconsole.log(htmlResult.html);\n// Output: \"<p>Bonjour <b>monde</b></p>\"\n```\n\n### CommonJS\n\n```javascript\nconst { TranslatePlusClient } = require('translateplus-js');\n\nconst client = new TranslatePlusClient({\n  apiKey: 'your-api-key'\n});\n\nclient.translate({\n  text: 'Hello',\n  source: 'en',\n  target: 'fr'\n}).then(result => {\n  console.log(result.translations.translation);\n});\n```\n\n## Documentation\n\n### Client Options\n\n```typescript\nconst client = new TranslatePlusClient({\n  apiKey: 'your-api-key',           // Required: Your TranslatePlus API key\n  baseUrl: 'https://api.translateplus.io', // Optional: API base URL\n  timeout: 30000,                    // Optional: Request timeout in ms (default: 30000)\n  maxRetries: 3,                     // Optional: Maximum retries (default: 3)\n  maxConcurrent: 5,                  // Optional: Max concurrent requests (default: 5)\n});\n```\n\n### Text Translation\n\n#### Single Translation\n\n```typescript\nconst result = await client.translate({\n  text: 'My client speaks only French. Will you translate for me?',\n  source: 'en',  // or 'auto' for auto-detection\n  target: 'fr'\n});\n\nconsole.log(result.translations.translation);\nconsole.log(result.translations.source);  // Detected source language\nconsole.log(result.translations.target);  // Target language\n```\n\n#### Batch Translation\n\n```typescript\nconst texts = [\n  'Hello, how are you?',\n  'What is your name?',\n  'Thank you very much!'\n];\n\nconst result = await client.translateBatch({\n  texts,\n  source: 'en',\n  target: 'fr'\n});\n\nconsole.log(`Total: ${result.total}`);\nconsole.log(`Successful: ${result.successful}`);\nconsole.log(`Failed: ${result.failed}`);\n\nresult.translations.forEach(translation => {\n  if (translation.success) {\n    console.log(`${translation.text} -> ${translation.translation}`);\n  } else {\n    console.log(`Error: ${translation.error}`);\n  }\n});\n```\n\n#### Concurrent Translation\n\n```typescript\nconst texts = ['Hello', 'Goodbye', 'Thank you', 'Please', 'Sorry'];\n\n// Translate all texts concurrently\nconst results = await client.translateConcurrent(texts, 'en', 'fr');\n\nresults.forEach((result, index) => {\n  if ('error' in result) {\n    console.log(`Error translating \"${texts[index]}\": ${result.error}`);\n  } else {\n    console.log(result.translations.translation);\n  }\n});\n```\n\n### HTML Translation\n\n```typescript\nconst htmlContent = `\n<html>\n  <body>\n    <h1>Welcome</h1>\n    <p>This is a <strong>test</strong> paragraph.</p>\n  </body>\n</html>\n`;\n\nconst result = await client.translateHTML({\n  html: htmlContent,\n  source: 'en',\n  target: 'fr'\n});\n\nconsole.log(result.html);\n// HTML structure is preserved, only text content is translated\n```\n\n### Email Translation\n\n```typescript\nconst result = await client.translateEmail({\n  subject: 'Welcome to our service',\n  email_body: '<p>Thank you for signing up!</p><p>We\\'re excited to have you.</p>',\n  source: 'en',\n  target: 'fr'\n});\n\nconsole.log(result.subject);    // Translated subject\nconsole.log(result.html_body);  // Translated HTML body\n```\n\n### Subtitle Translation\n\n```typescript\nconst srtContent = `1\n00:00:01,000 --> 00:00:02,000\nHello world\n\n2\n00:00:03,000 --> 00:00:04,000\nHow are you?\n`;\n\nconst result = await client.translateSubtitles({\n  content: srtContent,\n  format: 'srt',  // or 'vtt'\n  source: 'en',\n  target: 'fr'\n});\n\nconsole.log(result.content);\n// Timestamps are preserved, only text is translated\n```\n\n### Language Detection\n\n```typescript\nconst result = await client.detectLanguage('Bonjour le monde');\nconsole.log(result.language_detection.language);    // 'fr'\nconsole.log(result.language_detection.confidence);   // 0.99\n```\n\n### Supported Languages\n\n```typescript\nconst languages = await client.getSupportedLanguages();\nfor (const [code, name] of Object.entries(languages.languages)) {\n  console.log(`${code}: ${name}`);\n}\n```\n\n### Account Information\n\n```typescript\nconst summary = await client.getAccountSummary();\nconsole.log(`Credits remaining: ${summary.credits_remaining}`);\nconsole.log(`Current plan: ${summary.plan_name}`);\nconsole.log(`Concurrency limit: ${summary.concurrency_limit}`);\n```\n\n### i18n Translation Jobs\n\n#### Create Job\n\n```typescript\nconst result = await client.createI18nJob({\n  file_path: 'locales/en.json',\n  target_languages: ['fr', 'es', 'de'],\n  source_language: 'en',\n  webhook_url: 'https://your-app.com/webhook'  // Optional\n});\n\nconst jobId = result.job_id;\nconsole.log(`Job created: ${jobId}`);\n```\n\n#### Check Job Status\n\n```typescript\nconst status = await client.getI18nJobStatus(jobId);\nconsole.log(`Status: ${status.status}`);  // pending, processing, completed, failed\nconsole.log(`Progress: ${status.progress || 0}%`);\n```\n\n#### List Jobs\n\n```typescript\nconst jobs = await client.listI18nJobs(1, 20);\nfor (const job of jobs.results) {\n  console.log(`Job ${job.id}: ${job.status}`);\n}\n```\n\n#### Download Translated File\n\n```typescript\n// Download French translation\nconst content = await client.downloadI18nFile(jobId, 'fr');\nfs.writeFileSync('locales/fr.json', content);\n```\n\n#### Delete Job\n\n```typescript\nawait client.deleteI18nJob(jobId);\n```\n\n## Error Handling\n\nThe library provides specific exception types for different error scenarios:\n\n```typescript\nimport {\n  TranslatePlusClient,\n  TranslatePlusError,\n  TranslatePlusAPIError,\n  TranslatePlusAuthenticationError,\n  TranslatePlusRateLimitError,\n  TranslatePlusInsufficientCreditsError,\n  TranslatePlusValidationError,\n} from 'translateplus-js';\n\nconst client = new TranslatePlusClient({ apiKey: 'your-api-key' });\n\ntry {\n  const result = await client.translate({ text: 'Hello', source: 'en', target: 'fr' });\n} catch (error) {\n  if (error instanceof TranslatePlusAuthenticationError) {\n    console.error('Invalid API key');\n  } else if (error instanceof TranslatePlusInsufficientCreditsError) {\n    console.error('Insufficient credits');\n  } else if (error instanceof TranslatePlusRateLimitError) {\n    console.error('Rate limit exceeded');\n  } else if (error instanceof TranslatePlusAPIError) {\n    console.error(`API error: ${error.message}`);\n    console.error(`Status code: ${error.statusCode}`);\n  } else if (error instanceof TranslatePlusError) {\n    console.error(`Error: ${error.message}`);\n  }\n}\n```\n\n## Examples\n\n### Translate a List of Documents\n\n```typescript\nconst documents = [\n  'Document 1 content...',\n  'Document 2 content...',\n  'Document 3 content...',\n];\n\nconst results = await client.translateConcurrent(documents, 'en', 'fr');\n\nresults.forEach((result, index) => {\n  if ('error' in result) {\n    console.error(`Document ${index + 1} failed: ${result.error}`);\n  } else {\n    console.log(`Document ${index + 1}: ${result.translations.translation}`);\n  }\n});\n```\n\n### Translate HTML Email Template\n\n```typescript\nconst emailTemplate = `\n<html>\n  <body>\n    <h1>Welcome {{name}}!</h1>\n    <p>Thank you for joining us.</p>\n  </body>\n</html>\n`;\n\n// Translate to multiple languages\nconst languages = ['fr', 'es', 'de'];\nconst translations: { [key: string]: string } = {};\n\nfor (const lang of languages) {\n  const result = await client.translateHTML({\n    html: emailTemplate,\n    source: 'en',\n    target: lang\n  });\n  translations[lang] = result.html;\n}\n```\n\n## Requirements\n\n- Node.js 14.0.0 or higher\n- TypeScript 5.1+ (optional, for TypeScript projects)\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Support\n\n- **Documentation**: [https://docs.translateplus.io](https://docs.translateplus.io)\n- **API Reference**: [https://docs.translateplus.io/reference/v2/translation/translate](https://docs.translateplus.io/reference/v2/translation/translate)\n- **Issues**: [GitHub Issues](https://github.com/translateplus/translateplus-js/issues)\n- **Email**: support@translateplus.io\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Changelog\n\n### 2.0.0 (2024-01-12)\n\n- Initial release\n- Support for all TranslatePlus API endpoints\n- Concurrent translation support\n- Comprehensive error handling\n- Full TypeScript support\n- ESM and CommonJS support\n","readmeFilename":"README.md"}