inspiredminds / contao-remember-language
Contao 4 extension to redirect to a language saved in a cookie.
Fund package maintenance!
fritzmg
Installs: 140
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:contao-bundle
Requires
- php: >=7.1
- contao/core-bundle: ^4.9 || ^5.0
- symfony/config: ^4.4 || ^5.0 || ^6.0
- symfony/dependency-injection: ^4.4 || ^5.0 || ^6.0
- symfony/event-dispatcher: ^4.4 || ^5.0 || ^6.0
- symfony/http-foundation: ^4.4 || ^5.0 || ^6.0
- symfony/http-kernel: ^4.4 || ^5.0 || ^6.0
- symfony/routing: ^4.4 || ^5.0 || ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16 || ^3.0
README
Contao Remember Language
Contao 4 extension to redirect to a language saved in a cookie when using contao.prepend_locale: true
and requesting the domain without any language parameter in the URL.
Configuration
The extension allows you to configure the following:
- Enable or disable the redirect.
- Enable or disable saving the current language in a cookie.
- The name of the cookie.
# Default configuration for extension with alias: "contao_remember_language" contao_remember_language: # Enables the automatic redirect to the saved language. enable_redirect: true # Saves the current language as a cookie. save_language: true # Name of the cookie where the language is saved. cookie_name: contao_remember_language
Caching
If you use caching, make sure to not add the configured cookie to your COOKIE_WHITELIST
. The information of the cookie is only relevant for requests to https://example.org/
(without any path/parameter), and since Contao (at least up to Contao 4.9
) always redirects such requests (with a status code other than 301
) when using contao.prepend_locale: true
, such requests are never cached. Thus, it is not necessary to prevent caching when the request contains the cookie.