Skip to content

Translation strings not found in non-default domains when using named arguments #2483

@janklan

Description

@janklan

Versions:

  1. Plugin 2025.1.281
  2. PHPStorm: 2025.3, Build #PS-253.28294.345, built on December 8, 2025

Packages that might be relevant:

composer info | grep twig
symfony/twig-bridge                     7.3.8              Provides integration for Twig with various Symfony components
symfony/twig-bundle                     7.3.4              Provides a tight integration of Twig into the Symfony full-stack framework
symfony/ux-twig-component               2.31.0             Twig components for Symfony
twig/cache-extra                        3.22.1             A Twig extension for Symfony Cache
twig/cssinliner-extra                   3.22.0             A Twig extension to allow inlining CSS
twig/extra-bundle                       3.22.1             A Symfony bundle for extra Twig extensions
twig/html-extra                         3.22.1             A Twig extension for HTML
twig/inky-extra                         3.22.0             A Twig extension for the inky email templating engine
twig/intl-extra                         3.22.1             A Twig extension for Intl
twig/markdown-extra                     3.22.0             A Twig extension for Markdown
twig/string-extra                       3.22.1             A Twig extension for Symfony String
twig/twig                               3.22.1             Twig, the flexible, fast, and secure template language for PHP
vincentlanglet/twig-cs-fixer            3.11.0             A tool to automatically fix Twig code style

The described issue has existed for a long time, though.


PHPStorm is failing to detect an existing translation string in a non-default domain when using named arguments.

I'm not sure if this is a translation-specific bug, or whether it is a wider issue with recognition of named arguments added in Twig 3.15 which was released about a year ago.

{{ 'shared.button.open'|trans }} {# OK #}
{{ 'shared.button.open'|trans({}, 'messages') }} {# OK #}
{{ 'shared.button.open'|trans({}, domain: 'messages') }} {# OK #}
{{ 'shared.button.open'|trans(domain: 'messages') }} {# OK #}
{{ 'sla.compliance_by_milestone.header'|trans }} {# OK - Not found in the default domain #}
{{ 'sla.compliance_by_milestone.header'|trans({}, 'incident_reporting.messages') }} {# OK, found in a non-default domain #}
{{ 'sla.compliance_by_milestone.header'|trans({}, domain: 'incident_reporting.messages') }} {# BROKEN, should still be found #}
{{ 'sla.compliance_by_milestone.header'|trans(domain: 'incident_reporting.messages') }} {# BROKEN, should still be found #}

See the pic below. The yellow lines are highlighted as not found:

Image

Notably, the custom translation domains are not listed in the list of domains that show up when I click Add Translation:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions