From e0a6743af09dae8e3b2aaf7f309dd8be281409d3 Mon Sep 17 00:00:00 2001 From: Jonah Aragon Date: Thu, 11 Sep 2025 23:49:03 -0500 Subject: [PATCH] feat!: Enable zh-TW language (#3119) --- .github/workflows/build-pr.yml | 2 +- .github/workflows/publish-release.yml | 2 +- mkdocs.yml | 8 +++- run.sh | 6 +-- theme/assets/stylesheets/lang-zh-TW.css | 58 +++++++++++++++++++++++++ theme/layouts/home.yml | 2 +- theme/layouts/page.yml | 4 +- theme/layouts/pride.yml | 4 +- 8 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 theme/assets/stylesheets/lang-zh-TW.css diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index d996045f..c6e597ff 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -80,7 +80,7 @@ jobs: needs: [submodule, metadata] strategy: matrix: - lang: [es, fr, he, it, nl, ru, zh-Hant] + lang: [es, fr, he, it, nl, ru, zh-Hant, zh-TW] fail-fast: false uses: ./.github/workflows/build.yml with: diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index db3813f9..dd15f3c0 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -50,7 +50,7 @@ jobs: needs: submodule strategy: matrix: - lang: [en, es, fr, he, it, nl, ru, zh-Hant] + lang: [en, es, fr, he, it, nl, ru, zh-Hant, zh-TW] build: [build, offline] permissions: contents: read diff --git a/mkdocs.yml b/mkdocs.yml index 5216ebd5..14e1ac6b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -208,10 +208,14 @@ extra: link: /nl/ lang: nl icon: https://raw.githubusercontent.com/twitter/twemoji/master/assets/svg/1f1f3-1f1f1.svg - - name: 正體中文 + - name: 中文 (繁體) link: /zh-hant/ lang: zh-Hant - icon: https://raw.githubusercontent.com/twitter/twemoji/master/assets/svg/1f1ed-1f1f0.svg + icon: https://raw.githubusercontent.com/jdecked/twemoji/master/assets/svg/1f1ed-1f1f0.svg + - name: 中文 (繁體,台灣) + link: /zh-TW/ + lang: zh-TW + icon: https://raw.githubusercontent.com/jdecked/twemoji/master/assets/svg/1f1f9-1f1fc.svg - name: Русский link: /ru/ lang: ru diff --git a/run.sh b/run.sh index d24f3690..8a5117eb 100755 --- a/run.sh +++ b/run.sh @@ -100,14 +100,14 @@ if [ "$language" == "he" ]; then export BUILD_THEME_FONT_TEXT="Open Sans" fi -# Set font if chinese -if [ "$language" == "zh-Hant" ]; then +# Set font if russian or chinese +if [[ "ru zh-Hant zh-TW" =~ $language ]]; then export BUILD_THEME_FONT_CODE="Noto Sans TC" export BUILD_THEME_FONT_TEXT="Noto Sans TC" fi # Set stylesheet if hebrew or russian or chinese -if [[ "he ru zh-Hant" =~ $language ]]; then +if [[ "he ru zh-Hant zh-TW" =~ $language ]]; then export TRANSLATION_STYLESHEET="assets/stylesheets/lang-$language.css?v=20240410" fi diff --git a/theme/assets/stylesheets/lang-zh-TW.css b/theme/assets/stylesheets/lang-zh-TW.css new file mode 100644 index 00000000..fd78bb57 --- /dev/null +++ b/theme/assets/stylesheets/lang-zh-TW.css @@ -0,0 +1,58 @@ +/* +/// Copyright (c) 2023 Jonah Aragon +/// +/// Permission is hereby granted, free of charge, to any person obtaining a +/// copy of this software and associated documentation files (the "Software"), +/// to deal in the Software without restriction, including without limitation +/// the rights to use, copy, modify, merge, publish, distribute, sublicense, +/// and/or sell copies of the Software, and to permit persons to whom the +/// Software is furnished to do so, subject to the following conditions: +/// +/// The above copyright notice and this permission notice shall be included in +/// all copies or substantial portions of the Software. +/// +/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +/// DEALINGS +*/ + +/* chinese-traditional */ +@font-face { + font-family: 'Noto Serif TC'; + font-style: normal; + font-weight: 400; + src: url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-chinese-traditional-400-normal.woff2) format('woff2'), url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-chinese-traditional-400-normal.woff) format('woff'); +} + +/* latin */ +@font-face { + font-family: 'Noto Serif TC'; + font-style: normal; + font-weight: 400; + src: url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-latin-400-normal.woff2) format('woff2'), url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-latin-400-normal.woff) format('woff'); +} + +/* chinese-traditional */ +@font-face { + font-family: 'Noto Serif TC'; + font-style: normal; + font-weight: 700; + src: url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-chinese-traditional-700-normal.woff2) format('woff2'), url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-chinese-traditional-700-normal.woff) format('woff'); +} + +/* latin */ +@font-face { + font-family: 'Noto Serif TC'; + font-style: normal; + font-weight: 700; + src: url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-latin-700-normal.woff2) format('woff2'), url(https://fonts.bunny.net/noto-serif-tc/files/noto-serif-tc-latin-700-normal.woff) format('woff'); +} + +h1, h2, h3, .md-header__topic { + font-family: "Bagnard", "Noto Serif TC", serif; + font-weight: 700!important; +} diff --git a/theme/layouts/home.yml b/theme/layouts/home.yml index ab2223fa..3cbc7a65 100644 --- a/theme/layouts/home.yml +++ b/theme/layouts/home.yml @@ -11,7 +11,7 @@ definitions: - &font_family >- {%- if config.theme.language == "he" -%} Suez One - {%- elif config.theme.language == ("zh-Hant" or "ru") -%} + {%- elif config.theme.language == ("ru" or "zh-Hant" or "zh-TW") -%} Noto Sans TC {%- else -%} Public Sans diff --git a/theme/layouts/page.yml b/theme/layouts/page.yml index 1bee1429..9ac64112 100644 --- a/theme/layouts/page.yml +++ b/theme/layouts/page.yml @@ -19,7 +19,7 @@ definitions: - &title_font_family >- {%- if config.theme.language == "he" -%} Suez One - {%- elif config.theme.language == ("zh-Hant" or "ru") -%} + {%- elif config.theme.language == ("ru" or "zh-Hant" or "zh-TW") -%} Noto Serif TC {%- else -%} Bagnard @@ -35,7 +35,7 @@ definitions: - &font_family >- {%- if config.theme.language == "he" -%} Suez One - {%- elif config.theme.language == ("zh-Hant" or "ru") -%} + {%- elif config.theme.language == ("ru" or "zh-Hant" or "zh-TW") -%} Noto Sans TC {%- else -%} Public Sans diff --git a/theme/layouts/pride.yml b/theme/layouts/pride.yml index 461c0140..e97deabf 100644 --- a/theme/layouts/pride.yml +++ b/theme/layouts/pride.yml @@ -15,7 +15,7 @@ definitions: - &title_font_family >- {%- if config.theme.language == "he" -%} Suez One - {%- elif config.theme.language == ("zh-Hant" or "ru") -%} + {%- elif config.theme.language == ("ru" or "zh-Hant" or "zh-TW") -%} Noto Serif TC {%- else -%} Bagnard @@ -24,7 +24,7 @@ definitions: - &font_family >- {%- if config.theme.language == "he" -%} Suez One - {%- elif config.theme.language == ("zh-Hant" or "ru") -%} + {%- elif config.theme.language == ("ru" or "zh-Hant" or "zh-TW") -%} Noto Sans TC {%- else -%} Public Sans