inspiredminds/contao-remember-language

Contao 4 扩展,用于重定向到保存在cookie中的语言。

资助包维护!
fritzmg

安装: 135

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 3

分支: 0

开放问题: 0

类型:contao-bundle

2.0.1 2022-09-05 14:27 UTC

This package is auto-updated.

Last update: 2024-09-05 18:33:41 UTC


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时,没有必要防止缓存。