[PR #797] [MERGED] feat: add i18n support for backend API and Telegram bot #774

Closed
opened 2026-02-26 21:32:54 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797
Author: @dreamhunter2333
Created: 12/29/2025
Status: Merged
Merged: 12/30/2025
Merged by: @dreamhunter2333

Base: mainHead: feature/email


📝 Commits (2)

  • 29cd746 feat: add i18n support for backend API and Telegram bot
  • b483523 fix: improve Telegram bot language preference feature

📊 Changes

25 files changed (+762 additions, -276 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 CHANGELOG_EN.md (+2 -0)
📝 worker/src/admin_api/admin_user_api.ts (+18 -15)
📝 worker/src/admin_api/cleanup_api.ts (+30 -10)
📝 worker/src/admin_api/index.ts (+20 -15)
📝 worker/src/admin_api/ip_blacklist_settings.ts (+11 -18)
📝 worker/src/common.ts (+20 -15)
📝 worker/src/i18n/en.ts (+123 -0)
📝 worker/src/i18n/type.ts (+123 -0)
📝 worker/src/i18n/zh.ts (+123 -0)
📝 worker/src/mails_api/address_auth.ts (+2 -4)
📝 worker/src/mails_api/auto_reply.ts (+8 -5)
📝 worker/src/mails_api/index.ts (+7 -12)
📝 worker/src/mails_api/send_mail_api.ts (+18 -16)
📝 worker/src/mails_api/webhook_settings.ts (+5 -2)
📝 worker/src/telegram_api/common.ts (+18 -13)
📝 worker/src/telegram_api/index.ts (+8 -5)
📝 worker/src/telegram_api/miniapp.ts (+8 -7)
📝 worker/src/telegram_api/telegram.ts (+169 -95)
📝 worker/src/types.d.ts (+1 -0)

...and 5 more files

📄 Description

User description

Summary

  • 后端 API 错误消息全面支持中英文国际化
  • Telegram 机器人新增 /lang 命令设置语言偏好
  • Telegram 机器人命令描述支持双语显示
  • 用户语言偏好存储在 KV,支持个性化推送语言

Changes

  • 22 files modified (+735 / -272 lines)
  • 168 new i18n message keys (zh/en)

Test plan

  • Build passed
  • Lint passed
  • Test Telegram bot /lang command
  • Test API error messages in different languages

🤖 Generated with Claude Code


PR Type

enhancement, bug_fix, documentation


Description

  • Added comprehensive i18n support for backend API and Telegram bot.

    • Introduced bilingual error messages and command descriptions.
    • Added /lang command for Telegram bot to set language preferences.
    • User language preferences are stored in KV for personalized responses.
  • Refactored error handling to utilize i18n messages across APIs.

    • Centralized error messages for consistency and maintainability.
    • Enhanced validation and error feedback for various operations.
  • Updated documentation and changelogs to reflect i18n and Telegram enhancements.


Changes walkthrough 📝

Relevant files
Enhancement
16 files
telegram.ts
Add i18n support and `/lang` command for Telegram bot       
+147/-92
bind_address.ts
Integrate i18n for error messages in address binding         
+30/-26 
common.ts
Refactor common utilities to support i18n messages             
+20/-15 
index.ts
Add i18n support for admin API error handling                       
+20/-15 
send_mail_api.ts
Refactor mail API to use i18n for error messages                 
+18/-16 
cleanup_api.ts
Add i18n support for SQL cleanup validation and error handling
+30/-10 
passkey.ts
Integrate i18n for passkey-related operations                       
+10/-6   
auto_reply.ts
Add i18n support for auto-reply feature                                   
+8/-5     
webhook_settings.ts
Add i18n support for webhook settings validation                 
+5/-2     
user.ts
Refactor user API to include i18n error messages                 
+3/-6     
oauth2.ts
Add i18n support for OAuth2-related error messages             
+2/-4     
index.ts
Add i18n support for Telegram bot initialization                 
+7/-4     
address_auth.ts
Refactor address authentication to use i18n messages         
+2/-4     
settings.ts
Add i18n support for user settings API                                     
+1/-2     
miniapp.ts
Add i18n support for Telegram mini-app integration             
+8/-7     
ip_blacklist_settings.ts
Add i18n support for IP blacklist settings validation       
+11/-18 
Documentation
4 files
zh.ts
Add Chinese translations for new i18n messages                     
+122/-0 
en.ts
Add English translations for new i18n messages                     
+122/-0 
type.ts
Extend i18n type definitions for new messages                       
+122/-0 
CHANGELOG.md
Update changelog to include i18n and Telegram features     
+2/-0     
Additional files
4 files
CHANGELOG_EN.md +2/-0     
admin_user_api.ts +18/-15 
index.ts +7/-12   
common.ts +18/-13 

Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.

  • 🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

    ## 📋 Pull Request Information **Original PR:** https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797 **Author:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Created:** 12/29/2025 **Status:** ✅ Merged **Merged:** 12/30/2025 **Merged by:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Base:** `main` ← **Head:** `feature/email` --- ### 📝 Commits (2) - [`29cd746`](https://github.com/dreamhunter2333/cloudflare_temp_email/commit/29cd7466e804c0601dad773fdeb546ee3a3fd176) feat: add i18n support for backend API and Telegram bot - [`b483523`](https://github.com/dreamhunter2333/cloudflare_temp_email/commit/b4835230e39013cd47f943bdd8c8f2e97a1aa5d9) fix: improve Telegram bot language preference feature ### 📊 Changes **25 files changed** (+762 additions, -276 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `CHANGELOG_EN.md` (+2 -0) 📝 `worker/src/admin_api/admin_user_api.ts` (+18 -15) 📝 `worker/src/admin_api/cleanup_api.ts` (+30 -10) 📝 `worker/src/admin_api/index.ts` (+20 -15) 📝 `worker/src/admin_api/ip_blacklist_settings.ts` (+11 -18) 📝 `worker/src/common.ts` (+20 -15) 📝 `worker/src/i18n/en.ts` (+123 -0) 📝 `worker/src/i18n/type.ts` (+123 -0) 📝 `worker/src/i18n/zh.ts` (+123 -0) 📝 `worker/src/mails_api/address_auth.ts` (+2 -4) 📝 `worker/src/mails_api/auto_reply.ts` (+8 -5) 📝 `worker/src/mails_api/index.ts` (+7 -12) 📝 `worker/src/mails_api/send_mail_api.ts` (+18 -16) 📝 `worker/src/mails_api/webhook_settings.ts` (+5 -2) 📝 `worker/src/telegram_api/common.ts` (+18 -13) 📝 `worker/src/telegram_api/index.ts` (+8 -5) 📝 `worker/src/telegram_api/miniapp.ts` (+8 -7) 📝 `worker/src/telegram_api/telegram.ts` (+169 -95) 📝 `worker/src/types.d.ts` (+1 -0) _...and 5 more files_ </details> ### 📄 Description ### **User description** ## Summary - 后端 API 错误消息全面支持中英文国际化 - Telegram 机器人新增 `/lang` 命令设置语言偏好 - Telegram 机器人命令描述支持双语显示 - 用户语言偏好存储在 KV,支持个性化推送语言 ## Changes - 22 files modified (+735 / -272 lines) - 168 new i18n message keys (zh/en) ## Test plan - [x] Build passed - [x] Lint passed - [ ] Test Telegram bot /lang command - [ ] Test API error messages in different languages 🤖 Generated with [Claude Code](https://claude.com/claude-code) ___ ### **PR Type** enhancement, bug_fix, documentation ___ ### **Description** - Added comprehensive i18n support for backend API and Telegram bot. - Introduced bilingual error messages and command descriptions. - Added `/lang` command for Telegram bot to set language preferences. - User language preferences are stored in KV for personalized responses. - Refactored error handling to utilize i18n messages across APIs. - Centralized error messages for consistency and maintainability. - Enhanced validation and error feedback for various operations. - Updated documentation and changelogs to reflect i18n and Telegram enhancements. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>16 files</summary><table> <tr> <td><strong>telegram.ts</strong><dd><code>Add i18n support and `/lang` command for Telegram bot</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-a62d9c6ad0b04691396db4eecb38680ea80a2690f021e18baa6012ad525a27d3">+147/-92</a></td> </tr> <tr> <td><strong>bind_address.ts</strong><dd><code>Integrate i18n for error messages in address binding</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-ada3e8ad268246f0c99c97065551303c02fded466c73a4f525f6206cb49bdebf">+30/-26</a>&nbsp; </td> </tr> <tr> <td><strong>common.ts</strong><dd><code>Refactor common utilities to support i18n messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-fcc08fd5aa3c190d0d45c7e3dd208e5ee831d360b272fdd5869607cf472c5eb1">+20/-15</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Add i18n support for admin API error handling</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-b470c4c47ce4a700cd8aac644d07d8a747d439bb6d69e9392a198b3a931fe2e7">+20/-15</a>&nbsp; </td> </tr> <tr> <td><strong>send_mail_api.ts</strong><dd><code>Refactor mail API to use i18n for error messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-92070e9d7b3228209a2024053eb4429a76907de17f9566b97b22d0d12e4e0934">+18/-16</a>&nbsp; </td> </tr> <tr> <td><strong>cleanup_api.ts</strong><dd><code>Add i18n support for SQL cleanup validation and error handling</code></dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-29fba59415d40dbb12a6c3d99fae9e035c1faac3e2e78838779c0d7352c90577">+30/-10</a>&nbsp; </td> </tr> <tr> <td><strong>passkey.ts</strong><dd><code>Integrate i18n for passkey-related operations</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-cabc4dc44f7dd8ba02ec517fb6cf097f5f71e2fd01d122d55d306c119600684f">+10/-6</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>auto_reply.ts</strong><dd><code>Add i18n support for auto-reply feature</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-6876f417b59d14dc2e18dc5e749579049af9a0d6ded769a72ed8a13b966d632a">+8/-5</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>webhook_settings.ts</strong><dd><code>Add i18n support for webhook settings validation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-0c4fdb3ef2a70f77455a6458c649932abb800e668143eb85d12c95ef911bfb37">+5/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>user.ts</strong><dd><code>Refactor user API to include i18n error messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-aafbb1e6861a3f5ecb2bd9d51e2bf9f11f13aa96302eb755f91c233bae2a296e">+3/-6</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>oauth2.ts</strong><dd><code>Add i18n support for OAuth2-related error messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-fede9bc68112c797eefa07c6e6cc20a6aa107addb3e5636757131589a435e13b">+2/-4</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>index.ts</strong><dd><code>Add i18n support for Telegram bot initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-1d52cda4cdbe32be57c7e9c6428c778c7e5424e0ddb2f2a6e0408d0a39bf867d">+7/-4</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>address_auth.ts</strong><dd><code>Refactor address authentication to use i18n messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-ed5958370396967cd58454475686bcb4a4b36b338cd5bc6e0f27a34d0872f9cc">+2/-4</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>settings.ts</strong><dd><code>Add i18n support for user settings API</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-0e41b1cd8b40c15de837bee6cf774f29499e490f0b565b0f5556b549f7344dd3">+1/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>miniapp.ts</strong><dd><code>Add i18n support for Telegram mini-app integration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-6feb8b070d6d6d9eb8a7470cecf5cfa424c9ced860a94a085df2aa47cd11ba5e">+8/-7</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>ip_blacklist_settings.ts</strong><dd><code>Add i18n support for IP blacklist settings validation</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-02112f0b34b5d82117c3eebefb434860a3dba70dfd02f607796a0ba2a56c120f">+11/-18</a>&nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>zh.ts</strong><dd><code>Add Chinese translations for new i18n messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-afab3b78ff6b384c74a17417198e84933a9dfb3cd845fab91db1000084e192e1">+122/-0</a>&nbsp; </td> </tr> <tr> <td><strong>en.ts</strong><dd><code>Add English translations for new i18n messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-866bab2459173d441c05aaffe80d1c0d5aaef950056259c00364174c71a5b20c">+122/-0</a>&nbsp; </td> </tr> <tr> <td><strong>type.ts</strong><dd><code>Extend i18n type definitions for new messages</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-93a787364db63c92c7cff26f2a070af388094baa0b813de844843d5978808945">+122/-0</a>&nbsp; </td> </tr> <tr> <td><strong>CHANGELOG.md</strong><dd><code>Update changelog to include i18n and Telegram features</code>&nbsp; &nbsp; &nbsp; </dd></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed">+2/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Additional files</strong></td><td><details><summary>4 files</summary><table> <tr> <td><strong>CHANGELOG_EN.md</strong></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-77d2276dbbf8eb648363b81ea97049986b18e2cf1e90bd20fb5133ed5ff4fcae">+2/-0</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td><strong>admin_user_api.ts</strong></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-2843fd3d54aa9aa8054d2530e84a06de3068c31fd5c7d5246db5d2a4234a6196">+18/-15</a>&nbsp; </td> </tr> <tr> <td><strong>index.ts</strong></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-83710df6a60b2b512e134f32ad9890ab9a255040f6019f0d5603f72f4561cea4">+7/-12</a>&nbsp; &nbsp; </td> </tr> <tr> <td><strong>common.ts</strong></td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/797/files#diff-962b7426663cb9f82119a7691d62d1401a72e3c85654a12b7b21e014d1414eab">+18/-13</a>&nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
    kerem 2026-02-26 21:32:54 +03:00
    Sign in to join this conversation.
    No milestone
    No project
    No assignees
    1 participant
    Notifications
    Due date
    The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

    No due date set.

    Dependencies

    No dependencies set.

    Reference
    starred/cloudflare_temp_email#774
    No description provided.