inspiredminds / contao-remember-language
Contao 4 扩展,用于重定向到保存在cookie中的语言。
2.0.1
2022-09-05 14:27 UTC
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.prepend_locale: true
和请求不带任何语言参数的URL时,Contao 4 扩展用于重定向到保存在cookie中的语言。
配置
此扩展允许您配置以下内容
- 启用或禁用重定向。
- 启用或禁用保存当前语言到cookie。
- 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
缓存
如果您使用缓存,请确保不要将配置的cookie添加到您的 COOKIE_WHITELIST
中。cookie的信息仅对请求 https://example.org/
(不带任何路径/参数) 相关,并且由于 Contao (至少到 Contao 4.9
) 总是在使用 contao.prepend_locale: true
时重定向此类请求(状态码不同于 301
),因此此类请求永远不会被缓存。因此,当请求包含cookie时,没有必要防止缓存。