CodeIgniter Forums

Full Version: third locale detection
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
CI4 has 2 way of locale detection:

1. By url
Most modern websites use locale setting on some url part. But on complex url routing, this may not works (misinterpreted as segment or parameter instead of locale)

2. Content negotiation
Usually, browser has differ language than web. Some user wants to keep that. Also user may want to change language (force website for another language). So content negotiation cannot be used on this scenario.

I proposed 3rd way.

3. By Cookie.

My usecase:

My user can change website's language by clicking link which I put GET variable to that link. The new settings is saved on cookie.
When user visit, controller checks the cookie and GET variable,
- if both not present then using default locale
- if only one present, then that will be used
- if both present, then use setting from GET and change the cookie if differs from GET variable
That should not be part of the framework that is JavaScript and should be left to the user.