Skip to content

[Trans] Auto trans on devs content should not be a thing #153

@cavasinf

Description

@cavasinf

Edit: You committed something about that in menu.html.twig @kevinpapst
added method to configure translation domain for menu items (#150)

But still the case for the navbar

<a href="#" class="dropdown-item">{{ link.label|trans }}</a>

I'm currently experiencing some translation errors when using the menu and navbar.

What I got

From a subscriber, I implement some items to the menu.
These items have labels that are already translated inside the subscriber.

$changePassword = new MenuItemModel(
    'change_password', 
    $this->translator->trans('action.edit_profile'), // <----- HERE
    'user_edit', 
    ['user_uuid' => $user->getUuid()]
);
$event->addLink($changePassword);

What TablerBundle does

When TablerBundle print the twig result of the menu item, it tries to trans a content that is already translated.
Like {{ 'Modifier mon profil'|trans }}.

What is the problem?

Because of this, Symfony tells me that I have missing/wrong translations.

image

What is the solution?

  1. Add the trans domain to any trans function/filter that the bundle uses
    ❌ I don't think this is a good idea:
  • Translations like that are not auto discovered by bin/console translation:extract (huge nono for me)
  • I found it easier to expect as a dev, to do a "raw" print by the bundle if my label is a message ID.
  1. DO NOT try to translate content that devs define.
    Only word/phrase that we define in the bundle.
    ✔️ Rude, but I'll take it!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions