| name | zolinga-intl-translator |
| description | Use when working with the AI-powered translator service ($api->translator) for synchronous or asynchronous translation between system-supported languages. |
| argument-hint | <translate|translateAsync> <fromLang> <toLang> |
Zolinga Intl Translator
Use When
- Translating text between system-supported languages via AI.
- Setting up async translation pipelines with callback events.
- Configuring or overriding the translator AI backend.
- Customizing the translation prompt template.
Do Not Use When
- When asked to translate .po files or localize modules without explicitly stating that Zolinga Translator service should be used. In this case, use the
zolinga-intl-multilingual-support skill instead and edit the .po files directly.
Workflow
Synchronous Translation
$translated = $api->translator->translate(
string: 'Hello world',
fromLang: 'en_US',
toLang: 'cs_CZ',
context: 'Website greeting',
);
Asynchronous Translation
use Zolinga\Intl\Events\TranslateEvent;
$event = new TranslateEvent(
'my-unique-translation-id',
'my:callback',
request: [
'string' => 'Hello world',
'fromLang' => 'en_US',
'toLang' => 'cs_CZ',
'priority' => 0.8,
],
response: [
'recordId' => 42,
],
);
$api->translator->translateAsync($event);
Your callback listener receives the TranslateEvent with $event->response['data'] set.
Customizing the Prompt
Create config://zolinga-intl/translate-prompt.txt to override the default template. Available variables: {{SOURCE_LANG}}, {{SOURCE_CODE}}, {{TARGET_LANG}}, {{TARGET_CODE}}, {{CONTEXT}}, {{TEXT}}.
Backend Configuration
Override in config/local.json:
{
"ai": {
"backends": {
"translator": {
"model": "your-model",
"url": "http://your-host:3000/api"
}
}
}
}
Processing Async Jobs
bin/zolinga ai:generate --loop
Key Classes
Zolinga\Intl\TranslatorService — service registered as $api->translator
Zolinga\Intl\Events\TranslateEvent — event for async translation requests
- Listens on
ai:translation to complete the async round-trip
References
modules/zolinga-intl/wiki/Zolinga Intl/Translator.md
modules/zolinga-intl/src/TranslatorService.php
modules/zolinga-intl/src/Events/TranslateEvent.php
modules/zolinga-intl/data/translate-prompt.txt