Enterprise Network Configuration Guide

This comprehensive guide helps you configure Ltranslate for enterprise networks, intranets, and internal systems that may not be directly accessible from the internet.

Overview

Enterprise networks often have unique requirements for translation services, including security considerations, private networks, and internal systems. This guide addresses these specific needs.

POST Method Configuration

For internal systems that cannot be directly accessed, Ltranslate supports POST method submission to translate content:

API Endpoint

POST https://engine.ltranslate.cn/api/translate
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Request Body

{
  "source_lang": "en",
  "target_lang": "zh-cn",
  "html_content": "<html>Your HTML content here</html>",
  "url": "https://internal.company.com/page",
  "preserve_structure": true,
  "translate_meta": true
}

Response

{
  "success": true,
  "translated_content": "<html>Translated content here</html>",
  "source_lang": "en",
  "target_lang": "zh-cn",
  "character_count": 1250,
  "translation_time": 2.5
}

Internal Website Integration

JavaScript Integration

class EnterpriseTranslator {
    constructor(apiKey) {
        this.apiKey = apiKey;
        this.baseUrl = 'https://engine.ltranslate.cn/api';
    }

    async translateContent(htmlContent, targetLang) {
        try {
            const response = await fetch(`${this.baseUrl}/translate`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                    'Authorization': `Bearer ${this.apiKey}`
                },
                body: JSON.stringify({
                    source_lang: 'en',
                    target_lang: targetLang,
                    html_content: htmlContent,
                    preserve_structure: true
                })
            });

            const result = await response.json();
            return result.success ? result.translated_content : null;
        } catch (error) {
            console.error('Translation failed:', error);
            return null;
        }
    }

    // Translate entire page
    async translatePage(targetLang) {
        const htmlContent = document.documentElement.outerHTML;
        const translated = await this.translateContent(htmlContent, targetLang);
        
        if (translated) {
            document.documentElement.outerHTML = translated;
        }
    }
}

// Usage
const translator = new EnterpriseTranslator('YOUR_API_KEY');
// translator.translatePage('zh-cn');

Batch Processing

Multi-Page Translation

import requests
import json

class EnterpriseBatchTranslator:
    def __init__(self, api_key):
        self.api_key = api_key
        self.endpoint = 'https://engine.ltranslate.cn/api/translate'
        
    def translate_html_file(self, file_path, target_lang):
        """Translate a single HTML file"""
        with open(file_path, 'r', encoding='utf-8') as f:
            html_content = f.read()
            
        payload = {
            'source_lang': 'en',
            'target_lang': target_lang,
            'html_content': html_content,
            'preserve_structure': True
        }
        
        headers = {
            'Content-Type': 'application/json',
            'Authorization': f'Bearer {self.api_key}'
        }
        
        response = requests.post(self.endpoint, json=payload, headers=headers)
        
        if response.status_code == 200:
            result = response.json()
            return result.get('translated_content')
        else:
            raise Exception(f'Translation failed: {response.text}')
    
    def translate_directory(self, input_dir, output_dir, target_lang):
        """Translate all HTML files in a directory"""
        import os
        from pathlib import Path
        
        input_path = Path(input_dir)
        output_path = Path(output_dir)
        output_path.mkdir(parents=True, exist_ok=True)
        
        for html_file in input_path.glob('*.html'):
            print(f'Translating {html_file.name}...')
            
            try:
                translated = self.translate_html_file(html_file, target_lang)
                
                # Save translated file
                output_file = output_path / f'{html_file.stem}_{target_lang}.html'
                with open(output_file, 'w', encoding='utf-8') as f:
                    f.write(translated)
                    
                print(f'Successfully translated to {output_file}')
                
            except Exception as e:
                print(f'Failed to translate {html_file}: {e}')

# Usage
translator = EnterpriseBatchTranslator('YOUR_API_KEY')
# translator.translate_directory('input/', 'output/', 'zh-cn')

Security Configuration

API Key Management

# Environment variable configuration
export LTRANSLATE_API_KEY="your-api-key-here"

# Use in applications
API_KEY=${LTRANSLATE_API_KEY}

IP Whitelisting

Contact Ltranslate support to whitelist your enterprise IP ranges for enhanced security.

Proxy Configuration

Corporate Proxy Setup

// Configure proxy for enterprise networks
const translator = new EnterpriseTranslator(apiKey);

// Configure proxy settings
const proxyConfig = {
    host: 'proxy.company.com',
    port: 8080,
    auth: {
        username: 'proxy-user',
        password: 'proxy-pass'
    }
};

// Custom fetch with proxy
async function proxiedFetch(url, options) {
    const HttpsProxyAgent = require('https-proxy-agent');
    const agent = new HttpsProxyAgent(`http://${proxyConfig.auth.username}:${proxyConfig.auth.password}@${proxyConfig.host}:${proxyConfig.port}`);
    
    return fetch(url, {
        ...options,
        agent: agent
    });
}

Caching Strategy

Local Caching

class CachedTranslator extends EnterpriseTranslator {
    constructor(apiKey, cacheSize = 1000) {
        super(apiKey);
        this.cache = new Map();
        this.cacheSize = cacheSize;
    }

    async translateContent(htmlContent, targetLang) {
        const cacheKey = this.generateCacheKey(htmlContent, targetLang);
        
        // Check cache first
        if (this.cache.has(cacheKey)) {
            return this.cache.get(cacheKey);
        }
        
        // Translate and cache result
        const translated = await super.translateContent(htmlContent, targetLang);
        
        if (translated) {
            this.addToCache(cacheKey, translated);
        }
        
        return translated;
    }

    generateCacheKey(content, lang) {
        // Create hash from content and language
        return `${this.hashCode(content)}_${lang}`;
    }

    hashCode(str) {
        let hash = 0;
        for (let i = 0; i < str.length; i++) {
            const char = str.charCodeAt(i);
            hash = ((hash << 5) - hash) + char;
            hash = hash & hash; // Convert to 32-bit integer
        }
        return hash.toString();
    }

    addToCache(key, value) {
        if (this.cache.size >= this.cacheSize) {
            // Remove oldest entry
            const firstKey = this.cache.keys().next().value;
            this.cache.delete(firstKey);
        }
        this.cache.set(key, value);
    }
}

Monitoring and Analytics

Translation Metrics

class EnterpriseTranslationMonitor {
    constructor() {
        this.metrics = {
            totalTranslations: 0,
            successCount: 0,
            errorCount: 0,
            totalCharacters: 0,
            translationTime: []
        };
    }

    recordTranslation(success, characterCount, translationTime) {
        this.metrics.totalTranslations++;
        
        if (success) {
            this.metrics.successCount++;
            this.metrics.totalCharacters += characterCount;
            this.metrics.translationTime.push(translationTime);
        } else {
            this.metrics.errorCount++;
        }
    }

    getMetrics() {
        const avgTranslationTime = this.metrics.translationTime.length > 0
            ? this.metrics.translationTime.reduce((a, b) => a + b, 0) / this.metrics.translationTime.length
            : 0;

        return {
            ...this.metrics,
            successRate: (this.metrics.successCount / this.metrics.totalTranslations * 100).toFixed(2) + '%',
            averageTranslationTime: avgTranslationTime.toFixed(2) + 's',
            averageCharactersPerTranslation: Math.round(this.metrics.totalCharacters / this.metrics.successCount)
        };
    }
}

Best Practices

  • Security First: Never expose API keys in client-side code
  • Caching: Implement robust caching to reduce API calls and costs
  • Error Handling: Implement comprehensive error handling and retry logic
  • Monitoring: Monitor translation usage, costs, and performance
  • Testing: Test translations thoroughly before deployment
  • Backup: Keep backups of original content before translation

Common Use Cases

Internal Documentation

Translate internal wikis, documentation, and knowledge bases for multinational teams.

Intranet Applications

Make internal HR systems, dashboards, and applications accessible in multiple languages.

Customer Support

Translate support tickets, knowledge base articles, and customer communications.

Training Materials

Translate employee training materials, e-learning content, and corporate policies.

Next Steps

  • Assess your enterprise network requirements and security policies
  • Choose the appropriate integration method (API, POST, or batch processing)
  • Implement proper authentication and security measures
  • Set up monitoring and analytics for translation usage
  • Test thoroughly with your internal systems
  • Train your team on the new translation workflows

Enterprise Support

For enterprise-level support, custom integrations, or volume pricing, contact our enterprise team: