Skip to content

Parameters are not replaced under certain conditions #129

@zraly

Description

@zraly

I have a form with:

$form->setTranslator($this->translator->createPrefixedTranslator('admin.forms'));
$form->addText('name', 'name');

When the form is processed, I have:

if ...
$form['name']->addError($this->translator->translate('myError', ['errorType' => 'something']));

my admin.en.neon:

forms:
    myError: "This is %errorType%."

Latte:

<div n:foreach="$form['name']->errors as $error">{$error}</div>

This "constellation" returns: "This is %errorType%."
BUT when I change
$form['name']->addError($this->translator->translate('myError', ['errorType' => 'something']));
to
$form['name']->addError($this->translator->translate('admin.forms.myError', ['errorType' => 'something']));

it returns: "This is something."

So it translates even without full path, but it does not replace the parameters. When full path is provided, it replace the parameter correctly.
Maybe, there should be always full path (admin.forms.myError) in translate method, but why it translate it even without the full path, but does not replace the parameters?

(maybe there can be used {translator ...} tag somewhere in the latte file, but I am not sure how exactly it affect this)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage: Now

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions