From 29a01161258d082d2330e2931d9b578d968efcbc Mon Sep 17 00:00:00 2001 From: DmitrL-dev <84296377+DmitrL-dev@users.noreply.github.com> Date: Tue, 24 Mar 2026 15:23:33 +1000 Subject: [PATCH] feat: bilingual email templates + fix legacy domain in email.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SendVerificationCodeLocalized with RU/EN support - SendWelcome bilingual (dual-language body) - Fix отражение.рус -> syntrex.pro in code comment --- internal/infrastructure/email/email.go | 52 ++++++++++++++++++-------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/internal/infrastructure/email/email.go b/internal/infrastructure/email/email.go index 54d3919..ad2629f 100644 --- a/internal/infrastructure/email/email.go +++ b/internal/infrastructure/email/email.go @@ -109,7 +109,7 @@ type Service struct { // NewService creates an email service. // Pass nil sender for stub mode (logs only). -// For Resend: NewService(NewResendSender(apiKey, from), "SYNTREX", "noreply@отражение.рус") +// For Resend: NewService(NewResendSender(apiKey, from), "SYNTREX", "noreply@syntrex.pro") func NewService(sender Sender, fromName, fromAddr string) *Service { if sender == nil { sender = &StubSender{} @@ -128,53 +128,73 @@ func NewService(sender Sender, fromName, fromAddr string) *Service { } // SendVerificationCode sends a 6-digit verification code after registration. +// locale: "ru" for Russian, anything else for English. func (s *Service) SendVerificationCode(toEmail, userName, code string) error { - subject := "SYNTREX — Код подтверждения" + return s.SendVerificationCodeLocalized(toEmail, userName, code, "ru") +} + +// SendVerificationCodeLocalized sends a localized verification code email. +func (s *Service) SendVerificationCodeLocalized(toEmail, userName, code, locale string) error { + ru := locale == "ru" + var subject, greeting, instruction, validity, disclaimer string + if ru { + subject = "SYNTREX — Код подтверждения" + greeting = fmt.Sprintf("Здравствуйте, %s!", userName) + instruction = "Ваш код подтверждения email:" + validity = "Код действителен 24 часа." + disclaimer = "Если вы не регистрировались на SYNTREX — проигнорируйте это письмо." + } else { + subject = "SYNTREX — Verification Code" + greeting = fmt.Sprintf("Hello, %s!", userName) + instruction = "Your email verification code:" + validity = "This code is valid for 24 hours." + disclaimer = "If you did not sign up for SYNTREX, please ignore this email." + } body := fmt.Sprintf(`

🛡️ SYNTREX

-

Здравствуйте, %s!

-

Ваш код подтверждения email:

+

%s

+

%s

%s
-

Код действителен 24 часа.

+

%s

- Если вы не регистрировались на SYNTREX — проигнорируйте это письмо. + %s

-`, userName, code) +`, greeting, instruction, code, validity, disclaimer) return s.sender.Send(toEmail, subject, body) } // SendWelcome sends a welcome email after registration. func (s *Service) SendWelcome(toEmail, userName, orgName string) error { - subject := "Добро пожаловать в SYNTREX" + subject := "Welcome to SYNTREX / Добро пожаловать в SYNTREX" body := fmt.Sprintf(`

🛡️ SYNTREX

-

Здравствуйте, %s!

-

Ваша организация %s успешно зарегистрирована.

-

Как начать:

+

Hello / Здравствуйте, %s!

+

Your organization %s has been registered. / Ваша организация %s успешно зарегистрирована.

+

Getting Started / Как начать:

    -
  1. Откройте Quick Start в боковом меню
  2. -
  3. Создайте API-ключ в Настройки → API Keys
  4. -
  5. Отправьте первое событие безопасности
  6. +
  7. Open Quick Start in the sidebar / Откройте Quick Start в боковом меню
  8. +
  9. Create an API key in Settings → API Keys / Создайте API-ключ
  10. +
  11. Send your first security event / Отправьте первое событие

- Это автоматическое письмо от SYNTREX. Если вы не регистрировались — проигнорируйте. + This is an automated email from SYNTREX. If you did not register, please ignore it.

-`, userName, orgName) +`, userName, orgName, orgName) return s.sender.Send(toEmail, subject, body) }