Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameters are not replaced under certain conditions #129

Open
zraly opened this issue Apr 19, 2024 · 0 comments
Open

Parameters are not replaced under certain conditions #129

zraly opened this issue Apr 19, 2024 · 0 comments

Comments

@zraly
Copy link

zraly commented Apr 19, 2024

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)

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

No branches or pull requests

1 participant