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

Calc guard error message displays in wrong translation #265

Open
janherman opened this issue Feb 15, 2025 · 1 comment
Open

Calc guard error message displays in wrong translation #265

janherman opened this issue Feb 15, 2025 · 1 comment

Comments

@janherman
Copy link
Contributor

Describe the bug
I discovered if I fill wrong result in calc guard field, calc guard shows error message in English, even though my site is in Czech. This is the relevant part of the controller:

$form = new Form([
     // other rules ...
    "captcha" => [
        "rules" => ["required", "num"],
        "message" => "Vyplňte pole"
    ],
]);

This is the template:

<label>
    Vypňte výsledek příkladu <?= uniform_captcha() ?> =
    <?= captcha_field("", "contact-form__field"); ?>
</label>
<?php if(array_key_exists("captcha", $form->errors())): ?>
	<p class="contact-form__error"><?= $form->errors()["captcha"][0] ?></p>
<?php endif; ?>

Now, when I leave the captcha field blank, the returned error message is as defined in new Form().

But when I fill wrong result (let's say 3 + 3 = 77), English error message 'Please solve the arithmetic problem.' is returned.

Expected behavior
Czech error message should be shown.

Additional context
I tried it in Kirby 4.6.1 plainkit with the latest Uniform.

@janherman
Copy link
Contributor Author

janherman commented Mar 7, 2025

I found what causes this issue. It actually is Kirby itself. My site is single-language and the language is not English, which is default in Kirby. Turns out Kirby does not handle locale settings well on single-language pages. There is even a suggestion addressing this behavior on kirby.nolt.io

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

No branches or pull requests

1 participant