Files
hugo-theme-stack/i18n/zh-hant-tw.toml
T
4ad88a327e feat: add GDPR cookie consent banner (#1216)
* feat: add GDPR cookie consent banner

Add a GDPR-compliant cookie consent banner that gates analytics (Google
Analytics) and functional cookies (comments) until user consent is given.

Features:
- Theme-consistent styling using CSS variables (light/dark mode)
- Settings panel with category toggles (necessary, analytics, functional)
- Consent stored in cookie for 365 days
- Google Analytics only loads after analytics consent
- Comments only load after functional consent
- Translations for all 32 supported languages
- Accessible with proper ARIA attributes and focus management

Configuration in hugo.yaml:
  params:
    cookies:
      enabled: true
      categories:
        analytics: true
        functional: true

When cookies.enabled is false, scripts load normally without consent gating.

Closes #412

* refactor: move consent-gated GA to cookies/analytics.html

Move Google Analytics consent logic to avoid shadowing Hugo's internal
`_internal/google_analytics.html` template.

Changes:
- Rename google_analytics.html → cookies/analytics.html
- Update head.html to conditionally load:
  - cookies.enabled=true: cookies/analytics.html (consent-gated)
  - cookies.enabled=false: Hugo's _internal/google_analytics.html
- Align cookies/analytics.html with Hugo's internal template:
  - Support Privacy.GoogleAnalytics.Disable setting
  - Support Privacy.GoogleAnalytics.RespectDoNotTrack setting
  - Add UA- prefix deprecation warning

Note: Custom JS is required for consent-gated GA because Hugo templates
render at build time, but consent happens at runtime. We cannot call
Hugo's internal template after the user grants consent - we must
dynamically inject the GA script via JavaScript.

* style: indent cookies/analytics.html

* refactor: don't use default, put default configurations in params.toml

* fix: don't use `description` as translation key because it's reserved and will throw error

* fix: remove footer/components/custom-font.html call

* fix: banner showSettings key

* style: indent comments/include

* Add missing article.alert translation back

* style: format i18n toml files

* style: indent head/head.html

* style adjustment

* style: add missing -

* style: format demo/config/params.toml

* style: remove redundant comments from cookies.scss

* style: update box-shadow for cookie banner content

---------

Co-authored-by: delize <4028612+delize@users.noreply.github.com>
Co-authored-by: Jimmy Cai <jimmy@cai.im>
2026-02-19 17:21:25 +01:00

70 lines
1.9 KiB
TOML

toggleMenu = "切換選單"
darkMode = "夜晚模式"
[list]
section = "段落"
page = "第 {{ .Count }} 頁"
subsection = "小節"
[article]
back = "返回"
tableOfContents = "目錄"
relatedContent = "相關文章"
lastUpdatedOn = "最後更新"
readingTime = "閱讀時間: {{ .Count }} 分鐘"
[article.alert]
note = "備註"
tip = "提示"
important = "重要"
warning = "警告"
caution = "注意"
[notFound]
title = "404 錯誤"
subtitle = "頁面不存在"
[widget]
[widget.archives]
title = "紀錄"
more = "更多"
[widget.tagCloud]
title = "標籤雲"
[widget.categoriesCloud]
title = "分類"
[search]
title = "搜尋"
placeholder = "輸入關鍵字..."
resultTitle = "#PAGES_COUNT 個結果 (用時 #TIME_SECONDS 秒)"
[footer]
builtWith = "使用 {{ .Generator }} 建立"
designedBy = "主題 {{ .Theme }} 由 {{ .DesignedBy }} 設計"
[cookies]
title = "Cookie 同意"
text = "我們使用 Cookie 來增強您的瀏覽體驗並分析網站流量。"
acceptAll = "接受全部"
deny = "拒絕"
managePreferences = "管理偏好設定"
settingsTitle = "Cookie 偏好設定"
savePreferences = "儲存偏好設定"
cancel = "取消"
footerLink = "Cookie 設定"
commentsDisabled = "評論已停用,直到您接受功能性 Cookie。"
[cookies.necessary]
title = "必要"
text = "這些 Cookie 是網站運作所必需的,無法停用。"
[cookies.analytics]
title = "分析"
text = "這些 Cookie 幫助我們了解訪客如何與我們的網站互動。"
[cookies.functional]
title = "功能性"
text = "這些 Cookie 啟用評論和嵌入內容等功能."