Skip to content

feat(sms/i18n): 邀请/OTP 短信文案国际化(按用户 locale 渲染) #2815

Description

@os-zhuang

背景

#2780 的两处认证短信文案目前是英文硬编码在 packages/plugins/plugin-auth/src/auth-manager.ts

  • deliverPhoneOtp()"${code} is your ${appName} sign-in verification code. It expires in N minutes."(OTP 登录/重置共用模板)
  • sendPhoneInviteSms()"Your ${appName} account is ready. Sign in with this phone number using a verification code at ${baseUrl}, then set your password."

中文部署的员工收到英文短信,体验割裂。messaging sms channel 已经支持 (topic, 'sms', locale)sys_notification_template 渲染,但 auth 的 OTP/邀请发送走的是 services.sms.send 直连,不经过该模板机制。

诉求

  1. 按收件人 locale 渲染:OTP/邀请文案支持 locale 化——要么复用 sys_notification_template 的 locale fallback 机制(新增 auth.phone_otp / auth.phone_invite 主题模板 + 内置中英 seed),要么走 service-i18n 的翻译目录;locale 来源:sys_user.locale → 部署默认。
  2. 阿里云模板制的约束:阿里云短信本身按 TemplateCode 报备、无自由正文,locale 化对它意味着每语言一个 TemplateCode 的映射(如 aliyun_otp_template_code_zh / _en,或模板码表)。设计时需要与自由正文 provider(Twilio/log)统一在 SendSmsInput.templateId/templateParams 抽象下。
  3. 红线保持:无论哪种方案,OTP 码仍只出现在短信正文,不进模板渲染日志。

相关

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions