From 3081e31c80fb951b3c07a06b849d58fbf6d68732 Mon Sep 17 00:00:00 2001 From: Lxeon <1277454443@qq.com> Date: Fri, 6 Jun 2025 22:33:54 +0800 Subject: [PATCH 1/2] fix geoip chi and zho not return chinese translation --- extensions/geoip/geoip_util.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/geoip/geoip_util.cpp b/extensions/geoip/geoip_util.cpp index 0190595779..71cf05bc6a 100644 --- a/extensions/geoip/geoip_util.cpp +++ b/extensions/geoip/geoip_util.cpp @@ -183,6 +183,9 @@ const char *getLang(int target) if (translator->GetLanguageInfo(langid, &code, NULL)) { + if (strcmp(code, "chi") == 0 || strcmp(code, "zho") == 0) { + code = "zh-CN"; + } for (size_t i = 0; i < mmdb.metadata.languages.count; i++) { if (strcmp(code, mmdb.metadata.languages.names[i]) == 0) @@ -206,4 +209,4 @@ std::string lookupString(const char *ip, const char **path) } return std::string(result.utf8_string, result.data_size); -} \ No newline at end of file +} From 978a3fbfd899198ec49213ed81cc461653f57238 Mon Sep 17 00:00:00 2001 From: Lxeon <1277454443@qq.com> Date: Sat, 7 Jun 2025 14:15:35 +0800 Subject: [PATCH 2/2] optimize code logic: chi and zho as the final return --- extensions/geoip/geoip_util.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/geoip/geoip_util.cpp b/extensions/geoip/geoip_util.cpp index 71cf05bc6a..7787b99b44 100644 --- a/extensions/geoip/geoip_util.cpp +++ b/extensions/geoip/geoip_util.cpp @@ -183,9 +183,6 @@ const char *getLang(int target) if (translator->GetLanguageInfo(langid, &code, NULL)) { - if (strcmp(code, "chi") == 0 || strcmp(code, "zho") == 0) { - code = "zh-CN"; - } for (size_t i = 0; i < mmdb.metadata.languages.count; i++) { if (strcmp(code, mmdb.metadata.languages.names[i]) == 0) @@ -193,6 +190,9 @@ const char *getLang(int target) return code; } } + if (strcmp(code, "chi") == 0 || strcmp(code, "zho") == 0) { + return "zh-CN"; + } } }