Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ file that was distributed with this source code.
{% if nested_field.vars.translation_domain is same as(false) %}
{{ nested_field.vars.label }}
{% else %}
{% set translationDomain = nested_field.vars.translation_domain|default(nested_field.vars['sonata_admin'].admin.translationDomain) %}
Copy link
Copy Markdown
Contributor Author

@dmaicher dmaicher Oct 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way that nested_field.vars['sonata_admin'].admin.translationDomain was actually used as the translation domain?

if nested_field.vars.translation_domain is false then its the above if block anyway?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait. It can be null... changing it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the #6401 PR, it was:

nested_field.vars['sonata_admin'].admin.translationDomain|default(nested_field.vars.translation_domain)

Which mean it was used. And when it wasn't defined (like in your case) nested_field.vars.translation_domain was used instead.

The PR (with the bug), swap the default value.

I would say that if nested_field.vars.translation_domain is null it will fallback to nested_field.vars['sonata_admin'].admin.translationDomain, which is not a bad thing.

But if both nested_field.vars.translation_domain is null and nested_field.vars['sonata_admin'].admin.translationDomain is not defined ; what should we do ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if both are not available then we use null as the domain. The Symfony translator should handle it properly and use the default domain I think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the right solution indeed.

{% set translationDomain = nested_field.vars.translation_domain|default(nested_field.vars['sonata_admin'].admin.translationDomain|default(null)) %}
{{ nested_field.vars.label|trans({}, translationDomain) }}
{% endif %}
</th>
Expand Down