Download the PHP package neverendless/translator-client without Composer
On this page you can find all versions of the php package neverendless/translator-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download neverendless/translator-client
More information about neverendless/translator-client
Files in neverendless/translator-client
Package translator-client
Short Description PHP client for the Neverendless Translator REST API
License MIT
Informations about the package translator-client
Neverendless Translator — PHP Client
PHP client library for the Neverendless Translator REST API. Translate text via a self-hosted AI translation service with Redis caching.
Zero dependencies — uses PHP's built-in curl extension only.
Requires: PHP 8.1+ · ext-curl
Installation
Quick Start
Usage
Translate a string
Cache policies
Select the policy based on the message type — never forward a player-supplied value:
| Constant | Wire | Redis read | Redis write | Use case |
|---|---|---|---|---|
CachePolicy::NORMAL |
normal |
Yes | Yes (AI only) | Public chat |
CachePolicy::NO_STORE |
no_store |
Yes | Never | Private messages |
CachePolicy::BYPASS |
bypass |
No | Never | Sensitive content |
Language codes
The service accepts both normalized ISO-639-1 codes and full English names for backward compatibility:
The response always returns normalized codes in sourceLang and targetLang.
Health check
TranslationResult
| Property | Type | Description |
|---|---|---|
translation |
string |
Translated text (original on fallback) |
sourceLang |
string |
Detected source language — normalized code ('fr'), 'unknown', or 'mixed' |
targetLang |
string |
Target language — normalized code ('en') |
original |
string |
Original input text |
engine |
string |
'cache' · 'ai' · 'none' |
status |
string |
'success' · 'fallback' |
requestId |
?string |
Correlation ID echoed from the request |
resultCode |
int |
Stable numeric result code (see below) |
safeError |
string |
Bounded error description when resultCode > 0 |
Result codes:
| Code | Name | Meaning |
|---|---|---|
0 |
SUCCESS | A real cache or AI translation was produced |
1 |
FALLBACK | Original text returned; do not persist as translated |
2 |
INVALID_LANGUAGE | Unsupported target language |
3 |
INVALID_REQUEST | Malformed request |
4 |
TEXT_TOO_LARGE | Input exceeds the service size limit |
5 |
BUSY | Queue full — retry shortly |
6 |
MODEL_TIMEOUT | Ollama timed out |
7 |
SERVICE_UNAVAILABLE | Inference service unreachable |
8 |
INTERNAL_ERROR | Unexpected failure |
Helper methods: isSuccess() · isCacheHit() · isFallback() · isInvalidLanguage() · isBusy()
Timeout
Default is 150 seconds — must exceed the service's OLLAMA_TIMEOUT (default 120s) plus network headroom. Cache hits return in ~2–50ms regardless of timeout. For rendering-critical paths that cannot wait for AI inference, catch TranslatorException and display the original text:
Service Setup
This package is a client only. The translation service is a self-hosted Python microservice: github.com/Neverendless-WoW/TranslatorService
Tokens are configured in the service's environment. Never place tokens in browser JavaScript.
Releases
See GitHub releases page.
Versioning follows Semantic Versioning.
All versions of translator-client with dependencies
ext-curl Version *