Node.js SDK - Coming Soon
The LiveI18n Node.js SDK is currently in development and will provide server-side internationalization for Node.js applications and APIs.
Expected Features
Simple API Integration
const { LiveI18n } = require('@livei18n/node-sdk');
const translator = new LiveI18n({
apiKey: process.env.LIVEI18N_API_KEY,
customerId: process.env.LIVEI18N_CUSTOMER_ID
});
// Translate text
const result = await translator.translate('Welcome to our application!', {
targetLanguage: 'es-ES',
context: 'web application',
tone: 'friendly'
});
console.log(result.translated); // "¡Bienvenido a nuestra aplicación!"
Express.js Middleware
const express = require('express');
const { livei18nMiddleware } = require('@livei18n/node-sdk');
const app = express();
// Add LiveI18n middleware
app.use(livei18nMiddleware({
apiKey: process.env.LIVEI18N_API_KEY,
customerId: process.env.LIVEI18N_CUSTOMER_ID
}));
// Use translations in routes
app.get('/api/welcome', async (req, res) => {
const message = await req.translate('Welcome to our API!', {
targetLanguage: req.headers['accept-language'],
context: 'api response'
});
res.json({ message });
});
Batch Translation
// Translate multiple strings efficiently
const texts = [
'Welcome to our platform',
'Your account has been created',
'Please verify your email address'
];
const translations = await translator.translateBatch(texts, {
targetLanguage: 'fr-FR',
context: 'user onboarding'
});
console.log(translations);
// [
// { original: 'Welcome to our platform', translated: 'Bienvenue sur notre plateforme' },
// { original: 'Your account has been created', translated: 'Votre compte a été créé' },
// { original: 'Please verify your email address', translated: 'Veuillez vérifier votre adresse e-mail' }
// ]
Planned Features
🚀 High Performance
Built for server environments with connection pooling, request batching, and intelligent caching.
🔄 Multiple Frameworks Support
- Express.js middleware
- Fastify plugin
- Koa.js integration
- Next.js API routes
- Nest.js decorators
💾 Advanced Caching
- Redis integration
- Memory caching with TTL
- Distributed cache support
- Cache warming strategies
📊 Monitoring & Analytics
- Translation performance metrics
- Usage tracking and reporting
- Error monitoring and alerting
- Cost optimization insights
🔐 Enterprise Features
- Rate limiting and quotas
- API key rotation
- Audit logging
- Multi-tenant support
Framework Integrations
Express.js
const express = require('express');
const { createLiveI18nMiddleware } = require('@livei18n/node-sdk');
const app = express();
app.use(createLiveI18nMiddleware({
apiKey: process.env.LIVEI18N_API_KEY,
customerId: process.env.LIVEI18N_CUSTOMER_ID,
cache: {
type: 'redis',
url: process.env.REDIS_URL
}
}));
// Translation helper available in all routes
app.get('/products/:id', async (req, res) => {
const product = await getProduct(req.params.id);
const translatedDescription = await req.translate(product.description, {
targetLanguage: req.acceptsLanguages(),
context: 'product description'
});
res.json({
...product,
description: translatedDescription
});
});
Fastify
const fastify = require('fastify')({ logger: true });
// Register LiveI18n plugin
await fastify.register(require('@livei18n/node-sdk/fastify'), {
apiKey: process.env.LIVEI18N_API_KEY,
customerId: process.env.LIVEI18N_CUSTOMER_ID
});
fastify.get('/api/status', async (request, reply) => {
const message = await request.translate('System is operational', {
targetLanguage: request.headers['accept-language'],
context: 'system status'
});
return { status: 'ok', message };
});
Next.js API Routes
// pages/api/translate.js
import { createHandler } from '@livei18n/node-sdk/next';
const handler = createHandler({
apiKey: process.env.LIVEI18N_API_KEY,
customerId: process.env.LIVEI18N_CUSTOMER_ID
});
export default async function translate(req, res) {
if (req.method === 'POST') {
const { text, targetLanguage, context } = req.body;
const result = await handler.translate(text, {
targetLanguage,
context
});
res.json(result);
} else {
res.status(405).json({ error: 'Method not allowed' });
}
}
Use Cases
Email Templates
const sendWelcomeEmail = async (user) => {
const subject = await translator.translate('Welcome to our platform!', {
targetLanguage: user.preferredLanguage,
context: 'email subject',
tone: 'friendly'
});
const body = await translator.translate(
'Thank you for joining us. Get started by exploring our features.',
{
targetLanguage: user.preferredLanguage,
context: 'welcome email',
tone: 'encouraging'
}
);
await sendEmail({
to: user.email,
subject,
body
});
};
API Response Localization
const getLocalizedErrors = async (errors, language) => {
const errorMessages = {
'INVALID_EMAIL': 'Please provide a valid email address',
'PASSWORD_TOO_SHORT': 'Password must be at least 8 characters long',
'USER_NOT_FOUND': 'User not found'
};
const translatedErrors = {};
for (const [code, message] of Object.entries(errorMessages)) {
if (errors.includes(code)) {
translatedErrors[code] = await translator.translate(message, {
targetLanguage: language,
context: 'validation error',
tone: 'helpful'
});
}
}
return translatedErrors;
};
Background Job Processing
// Worker for translating content
const processTranslationJob = async (job) => {
const { contentId, targetLanguages } = job.data;
const content = await getContent(contentId);
const translations = await translator.translateBatch(
[content.title, content.body],
targetLanguages.map(lang => ({
targetLanguage: lang,
context: 'blog post',
tone: content.tone || 'informational'
}))
);
await saveTranslations(contentId, translations);
};
Estimated Timeline
- Alpha Release: Q2 2025
- Beta Release: Q3 2025
- Stable Release: Q4 2025
Performance Characteristics
Benchmarks (Projected)
- Throughput: 1000+ translations/second
- Latency: 50ms for cached translations
- Memory Usage: 100MB base footprint
- Cache Hit Rate: 90% with proper configuration
Optimization Features
- Connection Pooling: Efficient HTTP client management
- Request Batching: Combine multiple translations
- Intelligent Caching: Multi-layer caching strategy
- Background Processing: Queue intensive translation jobs
Stay Updated
Want to be the first to know when the Node.js SDK is ready?
- ⭐ Star our GitHub repository for updates
- 💬 Join our Discord for development discussions
- 📧 Subscribe to our newsletter for release announcements
- 🔔 Follow us on Twitter for behind-the-scenes updates
Alternative Solutions
While waiting for the Node.js SDK, you can:
Direct API Integration
const https = require('https');
const crypto = require('crypto');
class SimpleLiveI18n {
constructor(apiKey, customerId) {
this.apiKey = apiKey;
this.customerId = customerId;
this.cache = new Map();
}
generateCacheKey(text, options) {
const data = {
c: this.customerId,
t: text.trim().toLowerCase(),
l: (options.targetLanguage || '').toLowerCase(),
ctx: (options.context || '').trim().toLowerCase(),
tn: (options.tone || '').trim().toLowerCase()
};
return crypto
.createHash('sha256')
.update(JSON.stringify(data))
.digest('hex');
}
async translate(text, options = {}) {
const cacheKey = this.generateCacheKey(text, options);
if (this.cache.has(cacheKey)) {
return this.cache.get(cacheKey);
}
const payload = {
text,
locale: options.targetLanguage || 'auto',
tone: options.tone || '',
context: options.context || '',
cache_key: cacheKey
};
const response = await this.makeRequest('/api/v1/translate', payload);
this.cache.set(cacheKey, response.translated);
return response.translated;
}
makeRequest(path, data) {
return new Promise((resolve, reject) => {
const postData = JSON.stringify(data);
const options = {
hostname: 'api.livei18n.com',
port: 443,
path,
method: 'POST',
headers: {
'X-API-Key': this.apiKey,
'X-Customer-ID': this.customerId,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
};
const req = https.request(options, (res) => {
let body = '';
res.on('data', (chunk) => body += chunk);
res.on('end', () => {
try {
resolve(JSON.parse(body));
} catch (error) {
reject(error);
}
});
});
req.on('error', reject);
req.write(postData);
req.end();
});
}
}
// Usage
const translator = new SimpleLiveI18n(
process.env.LIVEI18N_API_KEY,
process.env.LIVEI18N_CUSTOMER_ID
);
const result = await translator.translate('Hello, world!', {
targetLanguage: 'es-ES',
context: 'greeting'
});
Contributing
Want to help shape the Node.js SDK?
- Requirements Gathering: Share your server-side i18n needs
- Architecture Review: Provide feedback on API design
- Beta Testing: Join our beta testing program
- Performance Testing: Help us optimize for your use cases
Questions & Feedback
Have questions about the Node.js SDK or specific requirements?
- GitHub Issues: Report bugs or request features
- Discord: Join our server-side development channel
- Email: Contact our backend team directly
- Docs Feedback: Help us improve this documentation
Ready to test the API? Use our React demo to test your API keys and see the translation quality you can expect from the Node.js SDK.