Created
December 23, 2015 14:47
-
-
Save bummzack/72bbf4bda56cba0e04d1 to your computer and use it in GitHub Desktop.
SilverStripe Controller that sets the default locale on all controllers upon init. Helps resolve translation issues.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ControllerExtension extends Extension | |
{ | |
public function onBeforeInit() | |
{ | |
// Ensure the locale is set properly on all requests (otherwise AJAX requests might return templates rendered | |
// with wrong locales). | |
i18n::set_default_locale(Config::inst()->get('i18n', 'default_locale')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apply in your config file: