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

Describe session-based language switching in docs #27

Closed
chillu opened this issue Jun 17, 2012 · 5 comments
Closed

Describe session-based language switching in docs #27

chillu opened this issue Jun 17, 2012 · 5 comments

Comments

@chillu
Copy link
Member

chillu commented Jun 17, 2012

Migrated from http://open.silverstripe.org/ticket/7044

Followup from #7041

The "Switching languages" section mentions the ?locale= GET param, and using that param would only show links to pages in a certain language. But some pages are statically linked, e.g. Security/login. Describe how to work around this by using session based locales through init(). Also fix usage of Translatable::set_reading_locale().

@Zauberfisch
Copy link
Contributor

this was just topic of conversation in IRC, and I took a crack at it, in the following gist is the work around I came up with.

https://gist.github.com/Zauberfisch/9226142

I simply hook into controller init and use session to remember the locale.
additionally the extension also provides a method to generate a list of languages this website exists in.

@tractorcow
Copy link
Contributor

@Zauberfisch Apologies for not looking at this in depth, but do you think it's worth migrating some of that initialisation into a RequestFilter? See https://github.com/silverstripe/silverstripe-framework/blob/3.1/control/VersionedRequestFilter.php for how Versioned does this.

I plan on using the same design pattern for the Fluent module once I get some time. :)

@Zauberfisch
Copy link
Contributor

hmm, what would be the benefit of hooking into preRequest() instead of onBeforeInit()?

@tractorcow
Copy link
Contributor

It wouldn't require a controller instance to do the initialisation of the locale. Probably... :)

It's also supposed to be the 'correct' way to do request-based pre-setup and post-teardown initialisation.

@maxime-rainville
Copy link

Unfortunately, Silverstripe CMS 3 has entered limited support in June 2018. This means we'll only be fixing critical bugs and security issues for Silverstripe CMS 3 going forward.

You can read the Silverstripe CMS Roadmap for more information on our support commitments.

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

No branches or pull requests

5 participants