aryehraber / statamic-captcha

Statamic Addon that protects your Statamic forms using a Captcha service.
MIT License
11 stars 8 forks source link

Adding translations not working #47

Closed RikHeynen closed 1 year ago

RikHeynen commented 1 year ago

When adding or publishing the translation messages the changes are not showing on the frontend when a validation error occurs.

Is it possible that this is not working a the moment in the current version?

aryehraber commented 1 year ago

Hi @RikHeynen,

To be completely honest, I've never needed translations with Captcha before, this feature was PRed by someone else. However, it should just work, unless something has changed on Statamic's side and this addon needs updating...

I assume you followed the instructions in the docs? Any additional info you can share so I can try to recreate the issue?

RikHeynen commented 1 year ago

Hello @aryehraber

Thank you for the reply.

Yes, i have followed the instructions in the docs.

I have a Statamic installation with 3 different sites in different languages: Dutch, English and German. In the docs was mentioned that the English and German translations already are set, but when going for example to the German site and filling in the form with Recaptcha and leaving the Captcha empty. The validation message is shown in English and not in German. The page html lang attribute has the correct language code.

I have also tried to publish the translation files but than always the English translation is shown. If i add manually a translation for Dutch the Dutch translation will be shown for all languages.

I noticed that when publishing the translation files the files are placed in the following folder structure: "resources/lang/vendor/captcha/{language}/messages.php", but in the docs is mentioned that a manually created file should be place in the following folder structure: ""resources/lang/vendor/statamic-captcha/{language}/messages.php"". I have tried the two different folder names but no works correct.

Thanks in advance!

aryehraber commented 1 year ago

Hi @RikHeynen, I finally had some time to look into this...

From my end everything seems to be working as expected, both the built-in languages (en & de) are working and I added a custom one (nl) after publishing the translation files as per the docs, which also works as expected.

I have a theory which hopefully solves it for you; did you happen to use Captcha in your project pre-v1.6.0 and upgrade along the way? If so, there may be an old config key which has since been deprecated and should be removed to allow the translation files to be used.

The following key in config/captcha.php should be deleted:

'error_message' => 'Captcha failed.' // value may be something different

If that isn't the case I may need temporary access to your project (or a test project with the same bug) to help debug further.

RikHeynen commented 1 year ago

Hello @aryehraber

Sorry for my late response. Thank you for doing research to it.

The old config key was already not set in the config/captcha.php, but i have found a solution to make this working in the project.

Further research is not needed anymore.

Thank you for the help!

aryehraber commented 1 year ago

@RikHeynen Alright cool, good to hear you found a solution 👍