WordPress tag cleaning practice (5): Solve the problem of Chinese labels remaining in the English language based on the php/go script, and realize the automatic tag merge and url jump
Preface
This article will introduce how to solve it completely The Chinese label problem remaining in the English language, and automate tag merge and URL jumps through Go scripts.
project address:https://github.com/shuijingwan/tag-merge
problem background
After completing the operations of the previous blogs, we found that there are still some Chinese tags that have not been processed under the English language:

Screenshot 1: Execute the command php fix-en-chinese-tags.php output, 10 failures
The main reasons for these failures are Alias has been used by other projects, for example:
❌ 修改失败: 此别名「console-command」已被其他项目使用。

Screenshot 6: In the background English language, based on the name sorting, it is found that there are some Chinese tags that have not been processed.
problem analysis

Screenshot 8: Failed Case Study
In the case of ‘Console commands’ as an example, the actual situation is as follows:
| Spoken language | tag name | Another name |
|---|---|---|
| Chinese (China) | console command | console command |
| Chinese (China) | console/command | console-command |
| english | console command | console command |
| english | console/command | console-command |
the root of the problem:
- There are two different tags in the Chinese language: ‘Console Command’ and ‘Console/Command’
- When trying to change the ‘Console command’ of the English language to ‘Console command’, slug
console-commandHas been occupied by ‘console/command’ - There are mappings in the translation cache:
'Console command': 'Console command'
Solution
Core ideas:Change the label name in Chinese language to English, so that the correct slug can be matched after translation.
operating steps
Step 1: Translate and modify the labels in Chinese language

Screenshot 10: Edit the tags under the English language
Will console/command console-command modify to Console command console-command-en

Screenshot 11: Edit the label in Chinese language
Will console/command console-command modify to Console Command Console-Command
Note: The background will be automatically added to English
-enSuffix, this is normal.



Screenshot 2-4: Verify Label Association
After the modification, the translation relationship between the Chinese ‘mouse cursor’ and the English ‘Mouse cursor’ remains unchanged.
Step 2: Regenerate label mapping

Screenshot 12: After re-executing the command go run main.go
go run main.go
generative output/tag_mapping_result.csv A new mapping record will appear:
1206,控制台命令,2723,console command,缓存匹配成功
Step 3: Execute tag merge

Screenshot 13: Execute the merge command
php merge-tags.php --all
php fix-en-chinese-tags.php
Output result:
📊 本次共成功合并: 10 组映射 (merge-tags.php)
已处理 0 个(fix-en-chinese-tags.php)
失败 0 个(fix-en-chinese-tags.php)
Step 4: Generate nginx 301 rules
Screenshot 14: View the generated rules

cd cmd/nginx-redirect/
go run main.go
output:
📋 已存在 50 条 Nginx 规则
📝 从 merge_log.json 生成 20 条新规则,跳过 0 条重复规则
✅ 成功追加 20 条新规则至 ../../output/nginx_redirect.conf

Screenshot 5: Verify 301 Jump
Access /en/tag/mouse cursor/ will jump to /en/tag/mouse-cursor/
Step 5: Manually handle remaining labels

Screenshot 15: Processing 3 remaining labels
For tags that do not exist in the translation cache, you need to manually modify them in the background.
Results summary
After this series of operations, we have implemented:
- ✅ All Chinese labels in English language are translated into English
- ✅ Automatically merge duplicate labels
- ✅ Generate 301 jump rules to pass weights
- ✅ Completely resolve 404 errors
Tool description
The main tools used in this project:
| Tool | Use |
|---|---|
main.go | Translate collision, generate label map CSV |
merge-tags.php | Execute tag merge |
fix-en-chinese-tags.php | Fix Chinese tags in English language |
nginx-redirect/main.go | Generate nginx 301 jump rules |
For detailed instructions, please refer to the project README.
Epilogue
Through the method introduced in this article, we have completely solved the problem of Chinese and English label confusion in the WordPress site. Most of the entire process is automated, which greatly improves work efficiency. Hope this series of articles is helpful to you!