craftcms / contact-form

Add a simple contact form to your Craft CMS site.
https://plugins.craftcms.com/contact-form
MIT License
294 stars 93 forks source link

Translation of fromName not working #235

Closed kevinmu17 closed 1 year ago

kevinmu17 commented 1 year ago

Description

Since the fromName is required since Craft 4 there is now a problem with the translation. 'Name' is not translated anymore.

Steps to reproduce

  1. <form method="post" action="" accept-charset="UTF-8">
    {{ csrfInput() }}
    {{ actionInput('contact-form/send') }}
    <h3><label for="from-name">Your Name</label></h3>
    {{ input('text', 'fromName', submission.fromName ?? '', {
        id: 'from-name',
        autocomplete: 'name',
    }) }}
    <h3><label for="from-email">Your Email</label></h3>
    {{ input('email', 'fromEmail', submission.fromEmail ?? '', {
        id: 'from-email',
        autocomplete: 'email',
    }) }}
    <h3><label for="subject">Subject</label></h3>
    {{ input('text', 'subject', submission.subject ?? '', {
        id: 'subject',
    }) }}
    <h3><label for="message">Message</label></h3>
    {{ tag('textarea', {
        text: submission.message ?? '',
        id: 'message',
        name: 'message',
        rows: 10,
        cols: 40,
    }) }}
    <button type="submit">Send</button>
    </form> 
  2. set your craft settings to any other than EN (i used NL)

Additional info

file: vendor/craftcms/contact-form/src/Mailer.php

if ($submission->fromName) {
    $fields[Craft::t('contact-form', 'Name')] = $submission->fromName;
}
brandonkelly commented 1 year ago

Contact Form 2.5.2 (Craft 3) and 3.0.1 (Craft 4) are out with Name and Email translations!