CloudyTrad provides language detection and translation capabilities for CloudyAI using a hybrid approach combining multiple detection libraries and LibreTranslate for neural translation.
- Hybrid Language Detection: Combines LibreTranslate, LanguageDetect, and franc-min
- Neural Translation: LibreTranslate for accurate translations
- Optimized for Short Text: Special handling for single words/phrases
- 50+ Languages: Supports major world languages
- API Authentication: Token-based security
cd CloudyTrad
npm installdocker-compose up -dThis starts LibreTranslate on port 5000.
Create .env file:
PORT=5001
API_TOKEN=your-secret-token-here
LIBRETRANSLATE_URL=http://localhost:5000
LIBRETRANSLATE_KEY=npm startDetect language of text.
Headers:
Authorization: Bearer your-secret-token-here
Content-Type: application/json
Request:
{
"q": "Bonjour le monde"
}Response:
[
{
"language": "fr",
"confidence": 0.95
}
]Translate text to target language.
Headers:
Authorization: Bearer your-secret-token-here
Content-Type: application/json
Request:
{
"q": "Hello world",
"target": "fr"
}Response:
{
"translatedText": "Bonjour le monde"
}Health check endpoint (no authentication required).
Response:
{
"status": "healthy",
"service": "CloudyTrad",
"libreTranslate": "http://localhost:5000"
}- LibreTranslate (Neural) - Primary detector for longer text
- LanguageDetect (N-gram) - Better for short text (<50 chars)
- franc-min (Statistical) - Fallback detector
- English (en)
- French (fr)
- Spanish (es)
- German (de)
- Italian (it)
- Portuguese (pt)
- And 40+ more...
See ISO_MAP in source code for full list.
LibreTranslate runs in Docker for neural translation:
version: '3'
services:
libretranslate:
image: libretranslate/libretranslate:latest
ports:
- "5000:5000"
environment:
- LT_LOAD_ONLY=en,fr,es,deAll endpoints except /health require authentication:
curl -X POST http://localhost:5001/detect \
-H "Authorization: Bearer your-secret-token-here" \
-H "Content-Type: application/json" \
-d '{"q":"Bonjour"}'| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 5001 |
API_TOKEN |
Authentication token | your-secret-token-here |
LIBRETRANSLATE_URL |
LibreTranslate service URL | http://localhost:5000 |
LIBRETRANSLATE_KEY |
LibreTranslate API key (if needed) | `` |
CloudyTrad is called by CloudyMod for language detection:
const response = await fetch('http://localhost:5001/detect', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-token',
'Content-Type': 'application/json'
},
body: JSON.stringify({ q: text })
});- Ensure Docker is running
- Check port 5000 is not in use
- Run
docker-compose logsfor errors
- Short text (<10 chars) may be less accurate
- Consider the hybrid approach prioritizes different detectors based on text length
- Verify LibreTranslate is running
- Check network connectivity
- Ensure target language is supported