survos / lingua-bundle
interact with Survos Lingua Server (aka translation server). Does not translate directly
Fund package maintenance!
Requires
- php: ^8.5
- survos/babel-bundle: ^2.10
- survos/kit-bundle: ^2.6
- survos/lingua-contracts: ^2.5
- survos/lingua-core: ^2.5
- symfony/config: ^7.4||^8.1
- symfony/console: ^7.4||^8.1
- symfony/dependency-injection: ^7.4||^8.1
- symfony/framework-bundle: ^7.4||^8.1
- symfony/http-client: ^7.4||^8.1
- symfony/http-kernel: ^7.4||^8.1
- symfony/remote-event: ^7.4||^8.1
- symfony/routing: ^7.4||^8.1
- symfony/webhook: ^7.4||^8.1
Requires (Dev)
- doctrine/orm: ^3.7
- symfony/messenger: ^7.4||^8.1
- symfony/phpunit-bridge: ^7.4||^8.1
Suggests
- ext-pdo_duckdb: Required only for storage: duckdb.
- survos/duckdb-bundle: Required only for storage: duckdb; must provide ConnectionCoordinator (coordinated PDO access).
- symfony/messenger: Required to actually receive translation.completed — the webhook endpoint dispatches a ConsumeRemoteEventMessage.
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.45.94
- 2.45.89
- 2.45.39
- 2.45.23
- 2.42.10
- 2.41.9
- 2.39.0
- 2.34.29
- 2.33.0
- 2.24.22
- 2.24.16
- 2.24.8
- 2.14.1
- 2.12.9
- 2.10.19
- 2.10.18
- 2.10.17
- 2.10.16
- 2.10.15
- 2.10.14
- 2.10.13
- 2.10.12
- 2.10.11
- 2.10.10
- 2.10.9
- 2.10.8
- 2.10.7
- 2.10.6
- 2.10.5
- 2.10.4
- 2.10.3
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.9.0
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.23
- 2.7.22
- 2.7.21
- 2.7.20
- 2.7.19
- 2.7.18
- 2.7.17
- 2.7.16
- 2.7.15
- 2.7.14
- 2.7.13
- 2.7.12
- 2.7.11
- 2.7.10
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.2
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.8
- 2.5.7
- 2.5.6
- 2.5.5
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.1
- 2.0.220
- 2.0.219
- 2.0.218
- 2.0.217
- 2.0.216
- 2.0.215
- 2.0.214
- 2.0.213
- 2.0.212
- 2.0.211
- 2.0.210
- 2.0.209
- 2.0.208
- 2.0.207
- 2.0.206
- 2.0.205
- 2.0.204
- 2.0.203
- 2.0.202
- 2.0.201
- 2.0.200
- 2.0.199
- 2.0.198
- 2.0.197
- 2.0.196
- 2.0.195
- 2.0.194
- 2.0.193
- 2.0.192
- 2.0.191
- 2.0.190
- 2.0.189
- 2.0.188
- 2.0.187
- 2.0.186
- 2.0.185
- 2.0.184
- 2.0.183
- 2.0.182
- 2.0.181
- 2.0.180
- 2.0.179
- 2.0.178
- 2.0.177
- 2.0.176
- 2.0.175
- 2.0.174
- 2.0.173
- 2.0.172
- 2.0.171
- 2.0.170
- 2.0.169
- 2.0.168
- 2.0.167
- 2.0.166
- 2.0.165
- 2.0.164
- 2.0.163
- 2.0.162
- 2.0.161
- 2.0.160
- 2.0.159
- 2.0.158
- 2.0.156
- 2.0.155
- 2.0.154
- 2.0.146
- 2.0.145
- 2.0.144
- 2.0.143
- 2.0.142
- 2.0.141
- 2.0.140
- 2.0.139
- 2.0.138
- 2.0.137
- 2.0.136
- 2.0.135
- 2.0.134
- 2.0.133
- 2.0.132
- 2.0.131
- 2.0.130
- 2.0.129
- 2.0.128
- 2.0.127
- 2.0.126
- 2.0.125
- 2.0.124
- 2.0.123
- 2.0.122
- 2.0.121
- 2.0.120
- 2.0.119
- 2.0.117
- 2.0.116
- 2.0.115
- 2.0.114
- 2.0.113
- 2.0.112
- 2.0.111
- 2.0.110
- 2.0.109
- 2.0.108
- 2.0.107
- 2.0.106
- 2.0.105
- 2.0.104
- 2.0.103
- 2.0.102
- 2.0.101
- 2.0.100
- 2.0.99
- 2.0.98
- 2.0.97
- 2.0.96
- 2.0.95
- 2.0.94
- 2.0.93
- 2.0.92
- 2.0.91
- 2.0.90
- 2.0.89
- 2.0.88
- 2.0.87
- 2.0.86
- 2.0.85
- 2.0.84
- 2.0.83
- 2.0.82
- 2.0.81
- 2.0.80
- 2.0.79
- 2.0.78
- 2.0.77
- 2.0.76
- 2.0.75
- 2.0.74
- 2.0.73
- 2.0.72
- 2.0.71
- 2.0.70
- 2.0.69
- 2.0.68
- 2.0.67
- 2.0.66
- 2.0.65
- 2.0.64
- 2.0.63
- 2.0.62
- 2.0.61
- 2.0.60
- 2.0.59
- 2.0.58
- 2.0.57
- 2.0.56
- 2.0.55
- 2.0.54
- 2.0.53
- 2.0.51
- 2.0.50
- 2.0.49
- 2.0.48
- 2.0.47
- 2.0.46
- 2.0.45
- 2.0.44
- 2.0.43
- 2.0.42
- 2.0.41
- 2.0.40
- 2.0.39
- 2.0.38
- 2.0.37
- 2.0.36
- 2.0.35
- 2.0.34
- 2.0.33
- 2.0.32
- 2.0.31
- 2.0.30
- 2.0.29
- 2.0.28
- 2.0.27
- 2.0.26
- 2.0.25
- 2.0.24
- 2.0.23
- 2.0.22
- 2.0.21
- 2.0.20
- 2.0.19
- 2.0.18
- 2.0.17
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
This package is auto-updated.
Last update: 2026-11-27 11:37:57 UTC
README
Synchronize application translation requests and results with the Lingua server. Babel supplies local translated values to application entities.
Features
- Twig extension with custom filters and functions
- Main service class for business logic
- Controller with example routes
- Console command for CLI operations
- Configurable via environment variables
Installation
Install the bundle using Composer:
composer require survos/lingua-bundle
If you're using Symfony Flex, the bundle will be automatically registered. Otherwise, add it to your config/bundles.php:
return [ // ... Survos\LinguaBundle\SurvosLinguaBundle::class => ['all' => true], ];
Configuration
Configure the bundle in config/packages/lingua.yaml:
survos_lingua: api_key: '%env(LINGUA_API_KEY)%'
Or set environment variables:
LINGUA_API_KEY=your_value_here
Usage
This bundle provides various components depending on your configuration. Check the generated service classes and controllers for specific usage examples.
Being told when a string is translated
Translation on the lingua server is asynchronous, and the historical way to collect results was
to poll with lingua:pull — a job that usually finds nothing, and that nobody schedules until a
locale turns up empty in production.
Set a callback URL and lingua announces them instead:
LINGUA_CALLBACK_URL=https://your-app.example/webhook/lingua LINGUA_WEBHOOK_SECRET=<same value the lingua server signs with>
lingua:push then sends each string's Str.code as a ref, the server records a subscription
per (string × target locale), and POSTs a signed translation.completed carrying up to 500
finished translations inline. TranslationUpdateApplier writes them to StrTranslation and
dispatches TranslationUpdatedEvent for app-specific work (reindexing, cache busting).
In the app:
# config/routes/webhook.yaml webhook: resource: '@FrameworkBundle/Resources/config/routing/webhook.php' prefix: /webhook # config/packages/webhook.yaml framework: webhook: routing: lingua: service: Survos\LinguaBundle\Webhook\LinguaWebhookRequestParser secret: '%env(default::LINGUA_WEBHOOK_SECRET)%' # config/packages/messenger.yaml — REQUIRED, or the endpoint's 202 is a lie framework: messenger: routing: 'Symfony\Component\RemoteEvent\Messenger\ConsumeRemoteEventMessage': lingua_callback
Leave LINGUA_CALLBACK_URL unset and nothing changes — no subscriptions are created and
lingua:pull remains the way to collect results.
Full contract: kit-bundle/docs/webhooks.md.
Replaced
LinguaWebhookController, which checked anX-Api-Keyby hand and whose route was never registered. See survos-sites/mediary#8.
Testing
Run the test suite:
./vendor/bin/phpunit
License
This bundle is released under the MIT license. See the LICENSE file for details.
Shared admin navigation
When menu-bundle is installed, Lingua contributes its available Overview and
Translation sandbox routes to ADMIN_NAVBAR_MENU. Tabler and EZ render the
same menu event; no application-specific listener is required. CLI/API-only
consumers do not need menu-bundle. Menu visibility is controlled by the layout;
it does not replace route authorization.
Optional local DuckDB storage (integration in progress)
The default remains application-database storage. The DuckDB implementation currently covers Lingua harvesting, push, pull, completion checks, and inbound callbacks. Babel entity registration, property hydration, catalogue loading, and translated search still use the application database. Do not enable this in an application yet: the Babel integration must be completed first so both sides select the same store.
The configuration being exercised by the storage/synchronization tests is:
survos_lingua: storage: '%env(LINGUA_STORAGE)%' duckdb_path: '%env(LINGUA_DUCKDB_PATH)%'
# .env — production stays on its existing app database LINGUA_STORAGE=app LINGUA_DUCKDB_PATH= # .env.local — once the Babel integration is available LINGUA_STORAGE=duckdb LINGUA_DUCKDB_PATH=/absolute/persistent/dummy-lingua.duckdb
DuckDB requires PDO DuckDB and survos/duckdb-bundle with ConnectionCoordinator.
Neither is loaded by the app backend. Unknown backend names fail rather than silently
falling back. The file's parent directory must already exist and be writable; keep it
outside disposable cache/build directories and on a local filesystem. Native WAL and
coordinated short transactions protect writers. Network calls happen after releasing
the file lock. Every process accessing the file must use the same coordinator.
The file contains two tables: str and str_tr, linked by str_code. Each source/target
locale pair has one canonical translation; engine records provenance. Blank results
never replace supplied text. Changing a stable catalogue key's source invalidates its
old translations. Callback replays are idempotent and unknown local requests are skipped.
Maintenance commands:
lingua:storage:status: selected backend and DuckDB coverage.lingua:storage:ensure es,fr: create missing DuckDB target requests.lingua:storage:import-app: seed an empty file from standard appstr/str_trtables without modifying them. Existing engine variants are projected using Babel's newest nonblank row preference; this is a canonical cache import, not an archival export of every provider row. Custom entity/table mappings are not supported by this pilot importer. It materializes the data in memory and is intended for small pilots.
Switching configuration never transfers data. The app and DuckDB stores are independent. TermSets remain application data. There is no migration, release, or production runtime change implied by installing the default app backend.