♻️ Refactored localization service

This commit is contained in:
2026-02-04 23:59:41 +08:00
parent c1669286f4
commit 9b6a62ec66
30 changed files with 530 additions and 369 deletions

View File

@@ -5,7 +5,7 @@ using DysonNetwork.Pass.Resources.Emails;
using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Localization;
using DysonNetwork.Shared.Localization;
using NodaTime;
using EmailResource = DysonNetwork.Pass.Localization.EmailResource;
@@ -15,7 +15,7 @@ public class MagicSpellService(
AppDatabase db,
IConfiguration configuration,
ILogger<MagicSpellService> logger,
IStringLocalizer<EmailResource> localizer,
ILocalizationService localizer,
EmailService email,
ICacheService cache
)
@@ -98,7 +98,7 @@ public class MagicSpellService(
await email.SendTemplatedEmailAsync<RegistrationConfirmEmail, LandingEmailModel>(
contact.Account.Nick,
contact.Content,
localizer["RegConfirmTitle"],
localizer.Get("regConfirmTitle"),
new LandingEmailModel
{
Name = contact.Account.Name,
@@ -110,7 +110,7 @@ public class MagicSpellService(
await email.SendTemplatedEmailAsync<AccountDeletionEmail, AccountDeletionEmailModel>(
contact.Account.Nick,
contact.Content,
localizer["AccountDeletionTitle"],
localizer.Get("accountDeletionTitle"),
new AccountDeletionEmailModel
{
Name = contact.Account.Name,
@@ -122,7 +122,7 @@ public class MagicSpellService(
await email.SendTemplatedEmailAsync<PasswordResetEmail, PasswordResetEmailModel>(
contact.Account.Nick,
contact.Content,
localizer["PasswordResetTitle"],
localizer.Get("passwordResetTitle"),
new PasswordResetEmailModel
{
Name = contact.Account.Name,
@@ -136,7 +136,7 @@ public class MagicSpellService(
await email.SendTemplatedEmailAsync<ContactVerificationEmail, ContactVerificationEmailModel>(
contact.Account.Nick,
contactMethod!,
localizer["ContractVerificationTitle"],
localizer.Get("contractVerificationTitle"),
new ContactVerificationEmailModel
{
Name = contact.Account.Name,