Skip to content

Add Chinese glossary (#772)#773

Open
LukasWallrich wants to merge 2 commits into
mainfrom
chinese-glossary-772
Open

Add Chinese glossary (#772)#773
LukasWallrich wants to merge 2 commits into
mainfrom
chinese-glossary-772

Conversation

@LukasWallrich
Copy link
Copy Markdown
Contributor

Summary

Closes #772.

  • Adds the Chinese (Simplified) translation of the FORRT glossary, sourced from the existing glossary spreadsheet (CN_* columns) — 262 entries plus a landing page at /glossary/chinese/ using the intro text from the issue.
  • Wires up Chinese throughout the glossary plumbing: 'CN': 'chinese' in _create_glossaries.py, a pinyin sort_key (via pypinyin, with leading punctuation stripped so titles starting with curly quotes / 《》 sort by their first Chinese character), a Chinese UI dictionary block in layouts/glossary/single.html (定义, 参考文献, 翻译, …), and a 中文 button in the language switcher.
  • Two incidental fixes ride along because the Chinese work surfaced them:
    • layouts/glossary/list.html now sorts the index TOC by Params.sort_key (matching single.html's per-term TOC) — without this the pinyin sort never reached the landing page since Hugo was falling back to filename order.
    • Pre-existing bug where every language's _index.md marked English as the active button regardless of page is fixed as a side effect of the shortcode refactor.

The first commit is a pure refactor (no Chinese), the second is the feature.

Refactor: language switcher → shortcode + data file (commit 1)

The hardcoded language-button HTML block was duplicated across each glossary _index.md (six files). Adding a future language was a six-file lockstep edit. Now there is a single source of truth:

  • data/glossary_languages.yaml — slug + label per language, in display order.
  • layouts/shortcodes/glossary_language_switcher.html — renders the buttons and resolves the active language from the page's directory (or an explicit current= arg).
  • Each _index.md is now {{< glossary_language_switcher >}} (or with current=\"<lang>\").

Adding the next language requires: one YAML entry, one new content/glossary/<slug>/_index.md, and one line in language_map in _create_glossaries.py.

Test plan

  • ~/go/bin/hugo builds clean (no errors, only pre-existing deprecation warning).
  • /glossary/chinese/ landing page renders the issue's intro text with the citation alert and Phase II call-to-action.
  • A sample Chinese term page (WEIRD → 西方的、受过教育的…) renders with the Chinese UI labels and full definition.
  • Chinese TOC is in pinyin order: AMNESIA → ARRIVE指南 → 版本控制 (banben) → … → JSON 文件 → 开放… (kaifang) → … → 西方的… (xifang), with 《旧金山…》 landing in the j block (jiujinshan) and "兄弟"式开放科学 in the x block (xiongdi).
  • Each language _index.md now marks its own button as active (English, German, Arabic, Turkish, Chinese all verified in built HTML).
  • Other language indexes (English, German) still sort their existing entries correctly after the list.html sort change.

🤖 Generated with Claude Code

LukasWallrich and others added 2 commits May 14, 2026 15:21
Replaces the hardcoded language-button HTML duplicated across each
glossary _index.md with a single shortcode driven by
data/glossary_languages.yaml. Adding a future language is now one
YAML entry rather than five lockstep edits.

Also fixes a pre-existing bug where every language's index marked
English as the active button regardless of which page the user was on
— the shortcode resolves the active language from the page's
directory (or an explicit current= arg).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the Chinese (Simplified) translation of the FORRT glossary,
sourced from the main glossary spreadsheet (CN_* columns):

- content/glossary/chinese/_index.md landing page with the Chinese
  background, citation note, and Phase II call-to-action.
- 262 translated term entries generated by _create_glossaries.py
  (which gains a 'CN': 'chinese' mapping and a Chinese branch in
  sort_key_for_language that sorts by pinyin and strips leading
  punctuation so titles starting with curly quotes or 《》 land at
  their natural pinyin position).
- Chinese UI dictionary block in layouts/glossary/single.html so
  per-term pages render labels like 定义, 参考文献, 翻译, etc.
- layouts/glossary/list.html now sorts the index TOC by
  Params.sort_key (matching what single.html already does for the
  per-term TOC), so the pinyin sort actually takes effect on the
  /glossary/chinese/ landing page.
- pypinyin added to requirements.txt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@LukasWallrich LukasWallrich requested a review from a team as a code owner May 14, 2026 07:22
@github-actions
Copy link
Copy Markdown
Contributor

📝 Spell Check Results

Found 25 potential spelling issue(s) when checking 30 changed file(s):

📄 content/glossary/german/_index.md

Line Issue
24 oder ==> order, older, coder, odder, odor, over, doer
26 oder ==> order, older, coder, odder, odor, over, doer
26 oder ==> order, older, coder, odder, odor, over, doer
26 oder ==> order, older, coder, odder, odor, over, doer
26 unter ==> under
26 Ressource ==> Resource
26 als ==> also
40 als ==> also
40 unser ==> under, unset, unsure, user
40 alle ==> all, alley
40 als ==> also
44 offen ==> often
46 Ressource ==> Resource

📄 content/glossary/turkish/_index.md

Line Issue
22 Bu ==> By, Be, But, Bug, Bun, Bud, Buy, Bum
22 bu ==> by, be, but, bug, bun, bud, buy, bum
22 Bu ==> By, Be, But, Bug, Bun, Bud, Buy, Bum
24 bu ==> by, be, but, bug, bun, bud, buy, bum
24 Bu ==> By, Be, But, Bug, Bun, Bud, Buy, Bum
24 bu ==> by, be, but, bug, bun, bud, buy, bum
26 Bu ==> By, Be, But, Bug, Bun, Bud, Buy, Bum
26 bu ==> by, be, but, bug, bun, bud, buy, bum
30 Bu ==> By, Be, But, Bug, Bun, Bud, Buy, Bum
42 Bu ==> By, Be, But, Bug, Bun, Bud, Buy, Bum
52 bu ==> by, be, but, bug, bun, bud, buy, bum

📄 layouts/glossary/single.html

Line Issue
32 Referenz ==> Reference

ℹ️ How to address these issues:

  1. Fix the typo: If it's a genuine typo, please correct it.
  2. Add to whitelist: If it's a valid word (e.g., a name, technical term), add it to .codespell-ignore.txt
  3. False positive: If this is a false positive, please report it in the PR comments.

🤖 This check was performed by codespell

@github-actions
Copy link
Copy Markdown
Contributor

👍 All image files/references (if any) are in webp format, in line with our policy.

@LukasWallrich
Copy link
Copy Markdown
Contributor Author

LukasWallrich commented May 14, 2026

⚠️ Staging Deployment Status

This PR was attempted for staging deployment but had merge conflicts and was skipped.

Attempted at: 2026-05-24 08:57:01 UTC
Staging URL: https://staging.forrt.org

Please resolve conflicts with the base branch and the deployment will be retried automatically.

Copy link
Copy Markdown
Contributor

@richarddushime richarddushime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🥇

ps: 我喜欢这个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Chinese glossary

2 participants