Translations in Kirby Uniform plugin

Hi,

My website has translations in three languages. I would like to know how i can translate the validation messages and success template of the Kirby Uniform plugin.

I’ve build my controller like the example in de docs: https://kirby-uniform.readthedocs.io/en/latest/examples/extended/

Instead of hardcoding the strings here

'message' => 'Please enter your name',

You can define the strings in your translations array for each language and the use the t() helper to fetch those strings.

'message' => t('name.message'),
 'translations' => [
    'name.message' => 'Please enter your name',
    'email.message' => 'Please enter your email',

  ]

Great! Thank you for the quick response.

I’m using ajax solution: https://kirby-uniform.readthedocs.io/en/latest/examples/ajax/ within Uniform and your suggestion not working. I’m getting string from default language. Same with panel field in email template.

Is there any difference when the form is submitted throu ajax?

Thanks

Hi. I have the same problem as illycz right now (and 3 years later).
Have you or someone else found a solution for this yet?

I have also tried the following without success … I get the message only in the default language

/**
 * Request Form
 */
[
   'pattern' => '(:any)',
   'method' => 'POST',
   'language' => 'en', // de is the default
    'action' => function($language) {
       $langcode = $language->code();

       $form = new \Uniform\Form([
           'name' => [
              'rules' => ['required'],
             //  'message' => t('requestFormMessageName'), // also does not work
             //  'message' => I18n::translate('requestFormMessageName', null,  $langcode), // also does not work
              'message' => t('requestFormMessageName', null,  $langcode), // not working
           ],
           ....
      ]
   }
],

Is that in a plugin? Or in the config? Which Kirby version?

Hi texnixe,

in the config. i found the error, it came from the rest of my code. i additionally overwrite the parent page slug … there was another error …

Thanks and best regards,
Robert