Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

mathspamprotection in site with translatable


Go to End


5 Posts   804 Views

Avatar
Guy Van Bael

Community Member, 61 Posts

22 May 2015 at 2:39am

I succesfully used userforms and mathspamprotection in numerous projects. But now i’m running into an issue with a multilingual site.
The question of mathspamprotection is always in the default language (in my case Dutch). When navigating to the english or french version of the site, the question is still in the default language.

Does anybode have a solution or workaround?

Avatar
Pyromanik

Community Member, 419 Posts

22 May 2015 at 3:17am

Seems like it should work: https://github.com/silverstripe/silverstripe-mathspamprotection/blob/master/code/MathSpamProtectorField.php#L138

Nothing jumps out at me as to why not, I can only guess that something is resetting the language or that it's not being detected correctly (or relies on the default locale, not the current locale).
You'll have to submit an issue or pull request to fix it I think.

Avatar
Guy Van Bael

Community Member, 61 Posts

22 May 2015 at 4:42am

This line in my _config.php triggers the language from the editablespamprotectionfield
18n::set_locale('nl_NL');

It always uses that value. If i uncomment this line, it always use en_US

Avatar
Guy Van Bael

Community Member, 61 Posts

22 May 2015 at 4:42am

This line in my _config.php triggers the language from the editablespamprotectionfield
18n::set_locale('nl_NL');

It always uses that value. If i uncomment this line, it always use en_US

Avatar
Guy Van Bael

Community Member, 61 Posts

22 May 2015 at 7:07pm

PROBLEM SOLVED

I ended up putting this line of code in the init function of my custom pagetype’s controller (contactpage)
i18n::set_locale($this->Locale);

Now it’s showing the mathspamprotectortext in the correct language when switching languages in a multilingual website with translatable and translatabledataobject.