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

Can't localise login:form errror/succes messages #7890

Closed
robdekort opened this issue Apr 12, 2023 · 3 comments · Fixed by #8924
Closed

Can't localise login:form errror/succes messages #7890

robdekort opened this issue Apr 12, 2023 · 3 comments · Fixed by #8924
Labels

Comments

@robdekort
Copy link
Contributor

robdekort commented Apr 12, 2023

Bug description

I'm trying to localise the error and success message in {{ user:login_form }} but they remain English. I've tried to add the strings to my nl.json file but that doesn't seem to work.

My sites.php:

'sites' => [
    'default' => [
        'name' => config('app.name'),
        'locale' => 'nl_NL',
        'url' => '/',
    ],
],

Marco Rieser suggested to rename nl.json to nl_NL.json and add 'lang' => 'nl_NL' to my default site. But that also doesn't work and it breaks all other localisable template strings.

How to reproduce

Use nl_NL as a locale
Add a user login form
Add those strings to the nl.json file:

"Invalid credentials.": "Ongeldige inloggegevens.",
"Login successful.": "Ingelogd.",

Note: the field does get translated when I add it to en.json (but obviously it shouldn't pick up that one).

Or DM me for repo access.

Logs

No response

Environment

Environment
Application Name: Stichting Lutje Geluk
Laravel Version: 9.52.5
PHP Version: 8.2.3
Composer Version: 2.2.7
Environment: local
Debug Mode: ENABLED
URL: lutjegeluk.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 5
Antlers: runtime
Stache Watcher: Enabled
Static Caching: Disabled
Version: 3.4.7 PRO

Statamic Addons
statamic/eloquent-driver: 1.2.0
studio1902/statamic-peak-browser-appearance: 1.0
studio1902/statamic-peak-commands: 1.27
studio1902/statamic-peak-seo: 1.7
studio1902/statamic-peak-tools: 2.5

Installation

Starter Kit using via CLI

Antlers Parser

runtime (new)

Additional details

No response

@robdekort
Copy link
Contributor Author

robdekort commented Apr 12, 2023

@jacksleight found out a little more:

This is curious, I just set app.locale to nl and got it working without having to add it myself.
OK I see, the UserController doesn't pull in Statamic's localize middleware (or the statamic.web middleware group), so the site's local isn't set correctly for the authentication request when the message is generated, only the application locale is used.

I can work around this particular issue as theres only error/succes message anyway, but still a bug I guess :-). Setting the app.locale to nl isn't an option as I don't want the CP in Dutch since we can't localise field labels etc.

@robdekort
Copy link
Contributor Author

An idea for a fix: #7892 (comment)

@robdekort
Copy link
Contributor Author

A final thought on the closed PR's that turned out not to be a full solution to the problem: it does seem a solution for folks not running multisite and not having English as their primary language. It wouldn't hurt others and make this bug less impactful.

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