This site is developed using Hugo, but I’ve always used Chinese titles, which results in less friendly generated article links. In simpler terms, when shared, they don’t look as good because the Chinese characters are escaped into formats like %E4%BD%A0%E5%A5%BD within the links. While you can solve this by setting a slug, it’s tedious to do manually every time.
Therefore, I decided to try using Claude4 to develop a translation assistant that automatically converts Chinese titles to English slugs and adds hyperlinks within the articles. This would eliminate the need for manual setup.
Claude4 is amazing – its contextual understanding has significantly improved, as has its efficiency in handling complex tasks.
Project Address
Domestic Project Address: https://cnb.cool/ttf248/hugo-content-suite International Project Address: https://github.com/ttf248/hugo-content-suite
Code Implementation
Let’s first discuss the implementation approach: We need to scan all articles, extract tag information and article titles, and then call on our local large model (such as gemma-3-12b-it) for translation.
In actual development, Claude4 showcased several significant advantages compared to previous generation large models. Due to the diverse functional requirements, Claude4 automatically designed an interactive menu, comprehensively considering various usage scenarios. For example, in tag processing, Claude4 not only supports tag statistics and analysis but also includes classification statistics and can even detect unlabeled articles. Furthermore, it provides preview and tag page generation functionalities.
Whether it’s integrating with local large models, adding translation caches, or performing large-scale code refactoring, Claude4 completes everything in one go, with almost no issues. Despite the relatively small project size, it includes many minor features. In previous development processes, large models often forgot earlier content, but Claude4 performed exceptionally well this time, virtually without any context forgetting issues.
In short, intelligence has increased, and we plan to switch to Claude4 for more development work as our primary coding model.
Translation Cache
This approach, besides reducing the number of calls to large models, performs quite efficiently when running a 12b model locally – it doesn’t waste much time. However, if you need to call the large model every time, it will still be somewhat slow. Furthermore, to fix the connections within articles, if a full update operation is executed and the article title is very long, there’s occasionally a situation where the two translated results differ, causing the link to change – which is quite awkward.
Feature Optimization
The entire project was handed over to Claude4
to analyze the space for optimization and obtain the following suggestions:
- Externalize Configuration - Improve maintainability and flexibility
- Structured Logging - Facilitate troubleshooting and monitoring
- Performance Monitoring - Understand system running status
- User Experience - Visual feedback such as progress bars
- Error Handling - A more robust exception handling mechanism
- Code Organization - Clearer module division
The code was reviewed, and there were no major issues, such as the configuration files. The original code’s configurations were converted to default settings, and if a corresponding configuration file wasn’t found during reading, a default one would be automatically generated to prevent user errors. Requirement: When translating text into English, dynamically calculate the current translation efficiency, estimate the remaining time, and output relevant information to the console: Now it has obtained the character count of the article, the character count for each line being translated, the translation time, and fits the calculation of the translation time for every 100 characters. Simultaneously, it calculates the estimated remaining translation time.
The code was completed, but the effect wasn’t very satisfactory, so I asked AI to provide a new design solution:
- Provide multiple efficiency calculation methods: Real-time efficiency, average efficiency, sliding window efficiency
- Improve display method: Progress bars, segmented statistics, dynamic refresh
- Add more useful metrics: API call counts, success rates, etc.
After the code was completed, a new surprise was discovered – translation efficiency statistics flooded in in real time, but without endless scrolling.
Translating text to English (total 7163 characters)...
Detected 53 lines to translate
[1/53] Stage1/6 [░░░░░░░░░░░░░░░░░░░░░░░░░] 1.9% Translating 354 characters...
✅ Completed (3.1s) | API Call #1
✅ Completed (1.5s) | API Call #2
✅ Completed (0.9s) | API Call #3
✅ Completed (0.2s) | API Call #4
✅ Completed (1.0s) | API Call #5
✅ Completed (1.0s) | API Call #6
✅ Completed (0.2s) | API Call #7
📊 Progress: 13.2% (7/53) | 12.9% (925/7163) 114.6 characters/second 📊
⚡ Efficiency: Real-time 76.4 | Average 117.9 | Recent 109.0 | Stage 113.6 characters/second 📊
🎯 Success Rate: 100.0% (7/7) | Remaining: 46 lines 7 seconds] 9.4% Translating 110 characters...
⏱️ Estimated remaining: 55s | Predicted completion time: 00:10:19 8s] 11.3% Translating 114 characters...
💾 Processing speed: 3211.3 lines/minute | Total time: 8s] 13.2% Translating 16 characters...
[8/53] Stage1/6 [███░░░░░░░░░░░░░░░░░░░░░░] 15.1% Translating 166 characters...
Previously, the control program wasn’t written with many features, so I was curious about how it was implemented and looked at the code:
// Clear screen and redisplay (dynamic refresh effect)
if translationCount > 1 {
fmt.Print("\033[6A\033[K") // Move up 6 lines and clear
}
Performance Statistics Menu
The newly added Performance Statistics Menu, which I myself designed, isn’t as well-designed as this one.
📊 Performance Statistics: 🔄 Translation Count: 360 ⚡ Cache Hit Rate: 1.4% (5/365) ⏱️ Average Translation Time: 315.927234ms 📁 File Operations: 73 ❌ Error Count: 0
- Data Mining
- Deep Learning
- Neural Network
Progress Bar Display
New Progress Bar Display, detailed progress, elapsed time, estimated remaining time. Please select function (0-13): 10 🔍 Collecting translation target… 📄 Loaded cache file, containing 0 translation records 📊 Translation Cache Statistics: 🏷️ Total tags: 229 📝 Total articles: 131 ✅ Cached: 0 🔄 To be translated: 360 Confirm to generate full translation cache? (y/n): y 🚀 Generating full translation cache… 📄 Loaded cache file, containing 0 translation records 🔍 Checking translations in cache… 🔄 Need to translate 360 new tags [░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 5/360 (1.4%) - Time taken: 3s - Estimated remaining: 3m8s 💾 Saved cache file, containing 5 translation records [█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 10/360 (2.8%) - Time taken: 6s - Estimated remaining: 3m28s 💾 Saved cache file, containing 10 translation records [██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 15/360 (4.2%) - Time taken: 9s - Estimated remaining: 3m30s 💾 Saved cache file, containing 15 translation records [██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 20/360 (5.6%) - Time taken: 13s - Estimated remaining: 3m36s 💾 Saved cache file, containing 20 translation records [███░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 25/360 (6.9%) - Time taken: 16s - Estimated remaining: 3m33s 💾 Saved cache file, containing 25 translation records [████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 30/360 (8.3%) - Time taken: 19s - Estimated remaining: 3m30s 💾 Saved cache file, containing 30 translation records [████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░] 35/360 (9.7%) - Time taken: 22s - Estimated remaining: 3m25s 💾 Saved cache file, containing 35 translation records
=== Hugo Blog Management Tool ===
🚀 Core Features
1. One-click full blog processing (complete blog workflow)
📝 Content Management
2. Generate tag pages
3. Generate article slugs
4. Translate articles into multi-language versions
💾 Cache Management
5. View cache status
6. Generate full translation cache
7. Clear translation cache
0. Exit the program