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

Validation errors in frontend are not shown in the locale of the current site #2387

Closed
cgrisar opened this issue Sep 8, 2020 · 12 comments
Closed
Assignees

Comments

@cgrisar
Copy link

cgrisar commented Sep 8, 2020

Bug Description

Validation errors in frontend are not shown in the locale of the current site

How to Reproduce

Create a multisite (sites.php)
Create a form with validation on the fields
Switch from one site to the other
Validation errors are only shown in "en" locale.

Extra Detail

Site in Dutch, validation errors in English
Screenshot 2020-09-08 at 17 19 41

Environment

Statamic version: 3.0.{?}

PHP version: 7.{?}

Install method (choose one):

  • Fresh install from statamic/statamic
  • Starter kit
  • Existing Laravel app
  • Other (please explain this magic!)
@jasonvarga
Copy link
Member

Please share:

  • your sites.php file
  • the path to the translation php file

@cgrisar
Copy link
Author

cgrisar commented Sep 8, 2020

Sites.php

'sites' => [

        'en' => [
            'name' => 'MIQ - English',
            'locale' => 'en_EN',
            'url' => '/',
        ],
        'nl' => [
            'name' => 'MIQ - Nederlands',
            'locale' => 'nl_NL',
            'url' => '/nl/',
        ],
        'fr' => [
            'name' => 'MIQ - Frans',
            'locale' => 'fr_FR',
            'url' => '/fr/',
        ],

    ],

Tried various combinations, including removing "en" site, or using "nl" and "fr" as value to locale key.

validation.php in

/resources/lang/en
/resources/lang/fr
/resources/lang/nl

The same folders I use when using the {{ trans }} tag

@cgrisar
Copy link
Author

cgrisar commented Sep 9, 2020

Small correction: the validation errors are shown in het locale as set in config/app.php

@robdekort
Copy link
Contributor

robdekort commented Sep 9, 2020

Not sure about this yet, but it seems the Dutch translations are out of date. Maybe this is why you don't see the correct error language. Related or not, I'll see if I can update those a.s.a.p.

@cgrisar
Copy link
Author

cgrisar commented Sep 9, 2020

It's not that, Rob

@robdekort
Copy link
Contributor

Good to know. I hope this issue can get bumped up then.

@robdekort
Copy link
Contributor

I can confirm this issue and just set up a demo project for core team to check this out. There's a contact form on the homepage. The homepage is in Dutch and if you send the form without any values you'll get back English error messages.

@robdekort
Copy link
Contributor

Is there any workaround known for this?

@jasonvarga jasonvarga self-assigned this Oct 14, 2020
@jasonvarga
Copy link
Member

Fixed for next release.

Make sure that you have the appropriate validation translation file in your resources/lang/{lang} directory.

For example, here's the French one: https://github.com/Laravel-Lang/lang/blob/master/src/fr/validation.php
That repo contains translations for a ton of languages.

@cgrisar
Copy link
Author

cgrisar commented Oct 14, 2020

Thanks Jason

@robdekort
Copy link
Contributor

Can anyone explain to me how it localised field validation should work? It kinda confuses me.

With the current Dutch validation.php in the repo I get a 'This field is required', but then nicely in Dutch. Fine by me, but not how it should be I guess.

If I replace the Dutch validation.php file with the one from the repo Jason mentioned, I get a 'ENGLISH FIELD NAME is verplicht' (part english, part dutch). It's nothing major but I'd like to understand :-)

@cgrisar
Copy link
Author

cgrisar commented Oct 15, 2020

Check the /nl/validation.php file

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

No branches or pull requests

3 participants