From edb96ae31c51e2e34593ca0834940440002bc2a2 Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Thu, 13 Feb 2025 15:58:12 +0100 Subject: [PATCH 01/11] fix language-not-found issues on repo page with simplified and traditional Chinese The author of github-readme-stats uses the non-standard code "cn" for simplified Chinese, see [here](https://github.com/anuraghazra/github-readme-stats?tab=readme-ov-file#available-locales). While for traditional Chinese the author only provides "zh-tw". The github-readme-stats functions on repo page will break if the user sets the site language to ALL variants of Chinese except for zh-tw. This hack is to make all sub-variants of simplified Chinese fall back to "cn" and all sub-variants of traditional Chinese fall back to "zh-tw". --- _includes/repository/repo.liquid | 14 ++++++++++++++ _includes/repository/repo_user.liquid | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/_includes/repository/repo.liquid b/_includes/repository/repo.liquid index 0f1afd42a46f..fcf61a924fb8 100644 --- a/_includes/repository/repo.liquid +++ b/_includes/repository/repo.liquid @@ -5,6 +5,20 @@ {% assign show_owner = true %} {% endif %} +{% assign lang = site.active_lang | split: '-' | first %} +{% if lang == 'pt' %} + {% assign lang = site.active_lang %} +{% endif %} +{% if lang == 'zh' %} + {% assign lang_last = site.active_lang | split: '-' | last %} + {% if lang_last == 'cn' or lang_last == 'sg' or lang_last == 'my' or lang_last == 'hans' %} + {% assign lang = 'cn' %} + {% elsif lang_last == 'tw' or lang_last == 'hk' or lang_last == 'mo' or lang_last == 'hant' %} + {% assign lang = 'zh-tw' %} + {% endif %} +{% endif %} +{% comment %} If you still encounter language-display issues, check the available locale codes in github-readme-stats (different from ISO-639 standard used in your website): https://github.com/anuraghazra/github-readme-stats?tab=readme-ov-file#available-locales {% endcomment %} + {% if site.data.repositories.repo_description_lines_max %} {% assign max_lines = site.data.repositories.repo_description_lines_max %} {% else %} diff --git a/_includes/repository/repo_user.liquid b/_includes/repository/repo_user.liquid index 7dc959f929ad..6721a6b3396e 100644 --- a/_includes/repository/repo_user.liquid +++ b/_includes/repository/repo_user.liquid @@ -1,3 +1,17 @@ +{% assign lang = site.active_lang | split: '-' | first %} +{% if lang == 'pt' %} + {% assign lang = site.active_lang %} +{% endif %} +{% if lang == 'zh' %} + {% assign lang_last = site.active_lang | split: '-' | last %} + {% if lang_last == 'cn' or lang_last == 'sg' or lang_last == 'my' or lang_last == 'hans' %} + {% assign lang = 'cn' %} + {% elsif lang_last == 'tw' or lang_last == 'hk' or lang_last == 'mo' or lang_last == 'hant' %} + {% assign lang = 'zh-tw' %} + {% endif %} +{% endif %} +{% comment %} If you still encounter language-display issues, check the available locale codes in github-readme-stats (different from ISO-639 standard used in your website): https://github.com/anuraghazra/github-readme-stats?tab=readme-ov-file#available-locales {% endcomment %} +