Form finisher translation


(Matthias Lang) #1

Hey there,

I have a form and would like to translate the finisher which includes a variable.
What is the best way to do that?

identifier: 'Neos.Form:Confirmation'
options:
  translation.enabled: true
  translation.package: 'Vendor.SitePackage'
  translation.locale: 'de'
  message: >
    <div class="h2">{name}, Ihre Nachricht ist angekommen.</div>
    <p>Vielen Dank für die Kontaktaufnahme, ich werde mich schnellstens um Ihr Anliegen kümmern.</p>
    <a href="/kontakt.html"><button>Zurück</button></a>

Thank you very much!
Matthias


(Stefan Bruggmann) #2

Hi @Matschess
I would create a custom Finisher by extending the existing one: https://github.com/neos/form/blob/master/Classes/Finishers/ConfirmationFinisher.php
And don’t forget to register the new Finisher: https://github.com/neos/form/blob/master/Configuration/Settings.yaml#L160

With $formRuntime you have access to the form values. So you can add your needed variables to the translator.


(Matthias Lang) #3

@newgen Thanks for the suggetion.
However, I’m not fit enough in php, so I would propably find a workaround or create a second form with an englisch finisher.

I just wondered because the form itself acutally is translatebale.


(Stefan Bruggmann) #4

@Matschess You’re right, this should be translatable too.
I added now a pull request to solve this: https://github.com/neos/form/pull/72

But this will take some time until it’s maybe added to a future version.


(Gökhan Sirin) #5

Seems to be possible in the meantime (with Neos 4).

In the yaml-Configuration of the form:

-
identifier: 'Neos.Form:Confirmation'
options:
  translation.id: 'angebotsformular-danke'

In the Main.xml translation file

<trans-unit id="angebotsformular-danke">
	<source><![CDATA[<h3>Vielen Dank!</h3><p>Wir haben Ihre Anfrage erhalten...</p>]]></source>
	<target><![CDATA[<h3>Thank you!</h3><p>We have received your request...</p>]]></target>
</trans-unit>