phalcon/cphalcon · error · Phalcon\Translate\Exceptions\MissingContent
Translation content was not provided
Error message
Translation content was not provided
What it means
The NativeArray adapter stores translations in a plain PHP array passed via the 'content' option; the constructor fetches options['content'] and throws Phalcon\Translate\Exceptions\MissingContent when the key is absent (phalcon/Translate/Adapter/NativeArray.zep:50). Here 'content' is the data array itself, unlike the Csv adapter where it is a file path.
Source
Thrown at phalcon/Translate/Adapter/NativeArray.zep:50
/**
* NativeArray constructor.
*
* @phpstan-param translate_array_options $options
*
* @throws InvalidDataType
* @throws MissingContent
*/
public function __construct(
<InterpolatorFactory> interpolator,
array options
) {
var data;
parent::__construct(interpolator, options);
if unlikely !fetch data, options["content"] {
throw new MissingContent();
}
if unlikely typeof data !== "array" {
throw new InvalidDataType();
}
let this->translate = data;
}
/**
* Check whether is defined a translation key in the internal array
*
* @deprecated
*/
public function exists(string index) -> bool
{
return this->has(index);
}View on GitHub (pinned to b7419de9cd)
Solutions
- Pass the dictionary: ['content' => ['key' => 'translation', ...]].
- When loading from a PHP file, ensure it ends with return [...]; and use ['content' => require $path].
- Assert array_key_exists('content', $options) in the factory that builds the adapter.
Example fix
// before
$t = new NativeArray($factory, ['triggerError' => true]);
// after
$t = new NativeArray($factory, [
'content' => require app_path('messages/en.php'),
]); Defensive patterns
Strategy: validation
Validate before calling
if (!array_key_exists('content', $options)) {
throw new InvalidArgumentException('NativeArray adapter requires the content option (translation array)');
}
$t = new NativeArray($factory, $options); Prevention
- Always build content via require of a file that ends with `return [...];`.
- Add a factory assertion that the loaded dictionary is a non-empty array.
- Remember: for NativeArray 'content' is the data itself, not a path.
When it happens
Trigger: new NativeArray($factory, ['triggerError' => true]) — any options array without a 'content' key.
Common situations: Translations included from a file that failed to load (include returning false/1 instead of an array); option named 'data' or 'translations'; options assembled in a branch that sometimes skips content; config caching that drops the entry.
Related errors
- Parameter 'content' is required
- Parameter 'locale' is required
- Parameter 'directory' is required
- Translation data must be an array
- Cannot find translation key: {key}
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/7c10b40b3b2dd9be.
Report an issue: GitHub.