I18nEntries - TranslateBehavior CRUD
This page describes the CRUD interface for managing translations stored in CakePHP's TranslateBehavior tables.
Overview
The I18nEntries controller provides:
- Overview of all translation tables in your database
- List, view, edit, and delete translation entries
- Batch auto-translation using configured translation engines
- Glossary suggestions from existing PO translations
- Support for both EAV and ShadowTable strategies
Supported Table Strategies
EAV Strategy (*_i18n tables)
Tables following the Entity-Attribute-Value pattern:
id- Primary keylocale- Language code (e.g.,de_CH,en_US)model- Model name (optional)foreign_key- Reference to the source recordfield- Name of the translated fieldcontent- The translated textauto- Boolean flag for machine translations (optional)
Example table name: articles_i18n
ShadowTable Strategy (*_translations tables)
Tables with direct field columns:
id- Foreign key to source recordlocale- Language code- Actual field columns (e.g.,
name,description,title) auto- Boolean flag for machine translations (optional)
Example table name: articles_translations
Auto Field
The auto boolean field is used to track whether a translation was:
- Machine-generated (
auto = true): Created by automatic translation - Manual (
auto = false): Created or edited by a human
Benefits
- Safe re-translation: Auto-translated entries can be safely overwritten when running batch translations
- Quality tracking: Easy identification of entries that need human review
- Workflow support: Filter to show only manual or only auto-translated entries
Adding the Auto Field
When generating migrations via the TranslateBehavior generator, check the "Include auto field" option. Or add it manually:
// In a migration
$table->addColumn('auto', 'boolean', [
'default' => false,
'null' => false,
'comment' => 'True if translation was machine-generated',
])->update();Usage
Routes
Loading Translate with routes registers these actions through the Admin prefix. No additional route block is needed.
Available Actions
| Action | URL | Description |
|---|---|---|
| index | /admin/translate/i18n-entries | Overview of all translation tables |
| entries | /admin/translate/i18n-entries/entries/{tableName} | List entries for a table |
| view | /admin/translate/i18n-entries/view/{tableName}/{id} | View single entry |
| edit | /admin/translate/i18n-entries/edit/{tableName}/{id} | Edit an entry |
| delete | /admin/translate/i18n-entries/delete/{tableName}/{id} | Delete an entry |
| autoTranslate | POST /admin/translate/i18n-entries/auto-translate/{tableName} | Batch translate entries |
| batchUpdateAuto | POST /admin/translate/i18n-entries/batch-update-auto/{tableName} | Mark entries as auto/manual |
Filtering
The entries list supports filtering by:
- Locale: Filter by language
- Field: Filter by translated field (EAV only)
- Auto/Manual: Filter by translation type (if
autofield exists) - Search: Full-text search in content
Auto-Translation
The auto-translate feature uses the configured translation engine (Google Translate, etc.) to translate entries. It:
- Gets the source text from the base table
- Translates to the target locale
- Marks a new machine translation as
auto = true. Filling empty fields in a row that already contains manual content preserves its manual classification.
Only entries with auto = true or empty content are translated to protect manual edits.
Glossary Suggestions
When viewing or editing an entry, glossary suggestions are shown from existing PO translations. This helps maintain consistent terminology across your application.
Configuration
The feature uses the standard Translate plugin configuration for translation engines:
// In config/app.php or config/app_local.php
'Translate' => [
'engine' => \Translate\Translator\Engine\Google::class,
],Security
- Table names are validated to prevent SQL injection
- Only tables ending with
_i18nor_translationsare accessible - System tables (migrations, queues, etc.) are excluded