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 %} +
Date: Thu, 13 Feb 2025 18:40:12 +0100 Subject: [PATCH 02/11] Update repo_user.liquid try to satisfy Prettier requirement --- _includes/repository/repo_user.liquid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/repository/repo_user.liquid b/_includes/repository/repo_user.liquid index 6721a6b3396e..6d1ad3a1df15 100644 --- a/_includes/repository/repo_user.liquid +++ b/_includes/repository/repo_user.liquid @@ -11,7 +11,7 @@ {% 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 %} - +
Date: Fri, 14 Feb 2025 08:13:22 +0100 Subject: [PATCH 03/11] Update repo.liquid switch to the `case-when` structure to make code eaiser to maintain in the future. --- _includes/repository/repo.liquid | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/_includes/repository/repo.liquid b/_includes/repository/repo.liquid index fcf61a924fb8..16c588abdb1c 100644 --- a/_includes/repository/repo.liquid +++ b/_includes/repository/repo.liquid @@ -6,17 +6,23 @@ {% 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 %} + +{% case lang %} + {% when 'pt' %} + {% assign lang = site.active_lang %} + + {% when 'zh' %} + {% assign lang_last = site.active_lang | split: '-' | last %} + {% case lang_last %} + {% when 'cn', 'sg', 'my', 'hans' %} + {% assign lang = 'cn' %} + {% when 'tw', 'hk', 'mo', 'hant' %} + {% assign lang = 'zh-tw' %} + + {% comment %} when... add a new language here if needed {% endcomment %} + {% endcase %} +{% endcase %} + {% 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 %} From a0636ef608267b38695068e9f2818001162e251b Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 08:14:50 +0100 Subject: [PATCH 04/11] Update repo_user.liquid switch to the `case-when` structure to make code eaiser to maintain in the future. --- _includes/repository/repo_user.liquid | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/_includes/repository/repo_user.liquid b/_includes/repository/repo_user.liquid index 6d1ad3a1df15..015aba25e4fb 100644 --- a/_includes/repository/repo_user.liquid +++ b/_includes/repository/repo_user.liquid @@ -1,15 +1,21 @@ {% 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 %} + +{% case lang %} + {% when 'pt' %} + {% assign lang = site.active_lang %} + + {% when 'zh' %} + {% assign lang_last = site.active_lang | split: '-' | last %} + {% case lang_last %} + {% when 'cn', 'sg', 'my', 'hans' %} + {% assign lang = 'cn' %} + {% when 'tw', 'hk', 'mo', 'hant' %} + {% assign lang = 'zh-tw' %} + + {% comment %} when... add a new language here if needed {% endcomment %} + {% endcase %} +{% endcase %} + {% 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 %}
From f7732f36fbf0e531681cee668dd6180b66d2b93c Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:13:33 +0100 Subject: [PATCH 05/11] Update repo.liquid implemented the requested change --- _includes/repository/repo.liquid | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_includes/repository/repo.liquid b/_includes/repository/repo.liquid index 16c588abdb1c..413d9d5cdbcd 100644 --- a/_includes/repository/repo.liquid +++ b/_includes/repository/repo.liquid @@ -5,24 +5,24 @@ {% assign show_owner = true %} {% endif %} -{% assign lang = site.active_lang | split: '-' | first %} +{% assign lang = site.lang | split: '-' | first %} {% case lang %} {% when 'pt' %} {% assign lang = site.active_lang %} {% when 'zh' %} - {% assign lang_last = site.active_lang | split: '-' | last %} + {% assign lang_last = site.lang | split: '-' | last %} {% case lang_last %} {% when 'cn', 'sg', 'my', 'hans' %} {% assign lang = 'cn' %} {% when 'tw', 'hk', 'mo', 'hant' %} {% assign lang = 'zh-tw' %} - - {% comment %} when... add a new language here if needed {% endcomment %} + {% endcase %} {% endcase %} +{% comment %} Add a new language using when... if needed {% endcomment %} {% 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 %} @@ -36,12 +36,12 @@ {{ include.repository }} {{ include.repository }}
From d9cd3b9c8ccce96eac70c27a777cc7148e146118 Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:15:48 +0100 Subject: [PATCH 06/11] Update repo_user.liquid implemented the requested change --- _includes/repository/repo_user.liquid | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_includes/repository/repo_user.liquid b/_includes/repository/repo_user.liquid index 015aba25e4fb..7acd6e1b1a85 100644 --- a/_includes/repository/repo_user.liquid +++ b/_includes/repository/repo_user.liquid @@ -1,21 +1,21 @@ -{% assign lang = site.active_lang | split: '-' | first %} +{% assign lang = site.lang | split: '-' | first %} {% case lang %} {% when 'pt' %} - {% assign lang = site.active_lang %} + {% assign lang = site.lang %} {% when 'zh' %} - {% assign lang_last = site.active_lang | split: '-' | last %} + {% assign lang_last = site.lang | split: '-' | last %} {% case lang_last %} {% when 'cn', 'sg', 'my', 'hans' %} {% assign lang = 'cn' %} {% when 'tw', 'hk', 'mo', 'hant' %} {% assign lang = 'zh-tw' %} - {% comment %} when... add a new language here if needed {% endcomment %} {% endcase %} {% endcase %} +{% comment %} Add a new language using when... if needed {% endcomment %} {% 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 %}
@@ -23,12 +23,12 @@ {{ include.username }} {{ include.username }}
From cc047cd937cc790ca9b0ae5f536e8ef24d4624ae Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:16:56 +0100 Subject: [PATCH 07/11] Update repo.liquid fixed a typo --- _includes/repository/repo.liquid | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/repository/repo.liquid b/_includes/repository/repo.liquid index 413d9d5cdbcd..05f1469a647a 100644 --- a/_includes/repository/repo.liquid +++ b/_includes/repository/repo.liquid @@ -9,7 +9,7 @@ {% case lang %} {% when 'pt' %} - {% assign lang = site.active_lang %} + {% assign lang = site.lang %} {% when 'zh' %} {% assign lang_last = site.lang | split: '-' | last %} @@ -18,7 +18,7 @@ {% assign lang = 'cn' %} {% when 'tw', 'hk', 'mo', 'hant' %} {% assign lang = 'zh-tw' %} - + {% endcase %} {% endcase %} From 032a295334e69bb940b9cb8c1fe8e7a9a335f39c Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:44:38 +0100 Subject: [PATCH 08/11] Update repo.liquid impleted the requested change --- _includes/repository/repo.liquid | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/repository/repo.liquid b/_includes/repository/repo.liquid index 05f1469a647a..7f1d0aa33f02 100644 --- a/_includes/repository/repo.liquid +++ b/_includes/repository/repo.liquid @@ -18,11 +18,11 @@ {% assign lang = 'cn' %} {% when 'tw', 'hk', 'mo', 'hant' %} {% assign lang = 'zh-tw' %} - {% endcase %} -{% endcase %} {% comment %} Add a new language using when... if needed {% endcomment %} +{% endcase %} + {% 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 %} From bc547f9d8b9900782f36af1c766d2d5397e49199 Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:45:20 +0100 Subject: [PATCH 09/11] Update repo_user.liquid implemented the requested change --- _includes/repository/repo_user.liquid | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/repository/repo_user.liquid b/_includes/repository/repo_user.liquid index 7acd6e1b1a85..2d15f5058af3 100644 --- a/_includes/repository/repo_user.liquid +++ b/_includes/repository/repo_user.liquid @@ -11,11 +11,11 @@ {% assign lang = 'cn' %} {% when 'tw', 'hk', 'mo', 'hant' %} {% assign lang = 'zh-tw' %} - {% endcase %} -{% endcase %} {% comment %} Add a new language using when... if needed {% endcomment %} +{% endcase %} + {% 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 %}
From 4360d23b1de6d9b51e389ee3a7320d38172726ea Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:27:31 +0100 Subject: [PATCH 10/11] Update repo.liquid tried my best to make prettier happy... --- _includes/repository/repo.liquid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/repository/repo.liquid b/_includes/repository/repo.liquid index 7f1d0aa33f02..c99b76b0117d 100644 --- a/_includes/repository/repo.liquid +++ b/_includes/repository/repo.liquid @@ -20,7 +20,7 @@ {% assign lang = 'zh-tw' %} {% endcase %} -{% comment %} Add a new language using when... if needed {% endcomment %} + {% comment %} Add a new language using when... if needed {% endcomment %} {% endcase %} {% 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 %} From 78e707a1f54746d9e6928fc25d8b8a258ef26a1f Mon Sep 17 00:00:00 2001 From: Jiaye Wu <161971145+jiaye-wu@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:27:55 +0100 Subject: [PATCH 11/11] Update repo_user.liquid tried my best to make prettier happy... --- _includes/repository/repo_user.liquid | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/repository/repo_user.liquid b/_includes/repository/repo_user.liquid index 2d15f5058af3..294d58a116e4 100644 --- a/_includes/repository/repo_user.liquid +++ b/_includes/repository/repo_user.liquid @@ -13,7 +13,7 @@ {% assign lang = 'zh-tw' %} {% endcase %} -{% comment %} Add a new language using when... if needed {% endcomment %} + {% comment %} Add a new language using when... if needed {% endcomment %} {% endcase %} {% 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 %}