symfony/translation · error · LogicException
Operated catalogues must belong to the same locale.
Error message
Operated catalogues must belong to the same locale.
What it means
Thrown by the constructor of AbstractOperation (and thus Operation and TargetOperation) when the two MessageCatalogue instances passed in do not share the same locale. The operation compares source and target messages domain by domain, which is only meaningful if both catalogues are in one locale; a locale mismatch would silently corrupt the diff, so the constructor rejects it up front with a LogicException.
Solutions
- Pass catalogues that were loaded for the same locale: check $source->getLocale() === $target->getLocale() before constructing the operation.
- Load each catalogue with LoaderInterface::load($resource, $locale) using the identical $locale argument.
- If cross-locale comparison is intended, load the source messages and build the target catalogue explicitly for that same locale instead of reusing a catalogue of another locale.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at Catalogue/AbstractOperation.php:68 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of symfony/translation@ae9e8a51bc (2026-09-15).
Data as JSON: /api/errors/5592445f1b1adbdd.
Report an issue: GitHub.
Appendix: source
Thrown at Catalogue/AbstractOperation.php:68
* ],
* ...
* ]
*
* @var array The array that stores 'all', 'new' and 'obsolete' messages
*/
protected array $messages;
private array $domains;
/**
* @throws LogicException
*/
public function __construct(
protected MessageCatalogueInterface $source,
protected MessageCatalogueInterface $target,
) {
if ($source->getLocale() !== $target->getLocale()) {
throw new LogicException('Operated catalogues must belong to the same locale.');
}
$this->result = new MessageCatalogue($source->getLocale());
$this->messages = [];
}
public function getDomains(): array
{
if (!isset($this->domains)) {
$domains = [];
foreach ([$this->source, $this->target] as $catalogue) {
foreach ($catalogue->getDomains() as $domain) {
$domains[$domain] = $domain;
if ($catalogue->all($domainIcu = $domain.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX)) {
$domains[$domainIcu] = $domainIcu;
}
}View on GitHub (pinned to ae9e8a51bc)