
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
idioma-sdk
Advanced tools
The Idioma SDK provides a programmatic interface for AI-powered translations with support for multiple file formats, providers, and cost tracking.
npm install idioma-sdk
# or
bun add idioma-sdk
import { Idioma } from 'idioma-sdk';
// Initialize the SDK
const idioma = await Idioma.create({
provider: 'anthropic',
apiKey: process.env.ANTHROPIC_API_KEY,
});
// Translate content
const result = await idioma.translateContent({
content: 'Hello World',
format: 'string',
sourceLocale: 'en',
targetLocale: 'es',
});
console.log(result.translatedContent); // "Hola Mundo"
// Create an instance using the async factory method
const idioma = await Idioma.create(config);
interface IdiomaConfig {
apiKey?: string; // API key for the provider
provider?: 'anthropic' | 'openai'; // AI provider (default: 'anthropic')
model?: string; // Model to use
cachePath?: string; // Path to lock file cache
locale?: {
source: string; // Source locale (default: 'en')
targets: string[]; // Target locales
};
translation?: {
frontmatterFields?: string[]; // Fields to translate in frontmatter
jsxAttributes?: string[]; // JSX attributes to translate
skipPatterns?: string[]; // Regex patterns to skip
};
}
translateContent(params)Translate content directly without file I/O.
const result = await idioma.translateContent({
content: '# Hello\nWorld',
format: 'md', // 'mdx' | 'md' | 'string'
sourceLocale: 'en',
targetLocale: 'es',
trackCosts: true, // Optional: track token usage and costs
});
// Result includes:
// - translatedContent: string
// - usage?: TokenUsage
// - cost?: CostCalculation
translateFile(params)Translate a single file with caching support.
const result = await idioma.translateFile({
filePath: 'content/docs/en/guide.mdx',
sourceLocale: 'en',
targetLocale: 'es',
outputPath: 'content/docs/es/guide.mdx', // Optional
showCosts: true, // Optional
});
// Result includes:
// - success: boolean
// - outputPath?: string
// - usage?: TokenUsage
// - cost?: CostCalculation
// - error?: string
translateFiles(params)Batch translate multiple files.
const result = await idioma.translateFiles({
patterns: ['content/**/*.mdx', 'docs/**/*.md'],
sourceLocale: 'en',
targetLocales: ['es', 'fr', 'de'],
showCosts: true,
});
// Result includes:
// - totalFiles: number
// - successCount: number
// - errorCount: number
// - totalUsage?: TokenUsage
// - totalCost?: CostCalculation
// - errors: Array<{file: string, error: string}>
estimateCost(params)Estimate translation costs before processing.
const estimate = await idioma.estimateCost({
patterns: ['content/**/*.mdx'],
targetLocales: ['es', 'fr'],
});
// Estimate includes:
// - estimatedFiles: number
// - estimatedTokens: number
// - estimatedCost: CostCalculation
// - breakdown: per-locale estimates
getAvailableFormats()Get supported file formats.
const formats = idioma.getAvailableFormats();
// Returns: ['mdx', 'md', 'string']
updateConfig(config)Update configuration at runtime.
idioma.updateConfig({
provider: 'openai',
model: 'gpt-4o-mini',
});
import { Idioma } from 'idioma';
const idioma = await Idioma.create({
provider: 'anthropic',
translation: {
frontmatterFields: ['title', 'description'],
jsxAttributes: ['alt', 'title', 'placeholder'],
},
});
// Translate all MDX files
const result = await idioma.translateFiles({
patterns: ['content/docs/**/*.mdx'],
sourceLocale: 'en',
targetLocales: ['es', 'fr', 'zh'],
showCosts: true,
});
console.log(`Translated ${result.successCount} files`);
console.log(`Total cost: ${result.totalCost?.formattedCost}`);
const result = await idioma.translateContent({
content: 'Your content here...',
format: 'mdx',
sourceLocale: 'en',
targetLocale: 'es',
trackCosts: true,
});
if (result.cost) {
console.log(`Translation cost: ${result.cost.formattedCost}`);
console.log(`Tokens used: ${result.usage?.totalTokens}`);
}
import { TranslationError, FileError } from 'idioma';
try {
const result = await idioma.translateFile({
filePath: 'path/to/file.mdx',
sourceLocale: 'en',
targetLocale: 'es',
});
} catch (error) {
if (error instanceof FileError) {
console.error('File error:', error.message);
} else if (error instanceof TranslationError) {
console.error('Translation error:', error.message);
}
}
const idioma = await Idioma.create({
provider: 'anthropic',
model: 'claude-v3.5-sonnet', // Optional, uses default with built-in fallbacks
});
const idioma = await Idioma.create({
provider: 'openai',
model: 'gpt-4o-2024-08-06', // Optional, uses default
apiKey: process.env.OPENAI_API_KEY,
});
The SDK includes built-in pricing for accurate cost calculation:
Access pricing information:
import { PRICING } from 'idioma';
console.log(PRICING);
MIT
FAQs
Idioma SDK for programmatic AI-powered translations
The npm package idioma-sdk receives a total of 1 weekly downloads. As such, idioma-sdk popularity was classified as not popular.
We found that idioma-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.