Skip to content

Parameters are not replaced under certain conditions #129

Open
@zraly

Description

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions