🐛 Bug fixes on localization

This commit is contained in:
2025-02-01 18:21:54 +08:00
parent b68aed0284
commit cd01657857
11 changed files with 21 additions and 10 deletions

View File

@ -19,7 +19,7 @@ const FallbackLanguage = "en-US"
var LocaleBundle *i18n.Bundle
func LoadLocalization() error {
LocaleBundle = i18n.NewBundle(language.English)
LocaleBundle = i18n.NewBundle(language.AmericanEnglish)
LocaleBundle.RegisterUnmarshalFunc("json", json.Unmarshal)
var count int

View File

@ -128,10 +128,15 @@ func ActiveTicket(ticket models.AuthTicket) (models.AuthTicket, error) {
if err := database.C.Save(&ticket).Error; err != nil {
return ticket, err
} else {
var account models.Account
if err := database.C.Where("id = ?", ticket.AccountID).Select("Language").First(&account).Error; err != nil {
return ticket, nil
}
_ = NewNotification(models.Notification{
Topic: "passport.security.alert",
Title: GetLocalizedString("subjectLoginAlert", ticket.Account.Language),
Body: fmt.Sprintf(GetLocalizedString("shortBodyLoginAlert", ticket.Account.Language), ticket.IpAddress),
Title: GetLocalizedString("subjectLoginAlert", account.Language),
Body: fmt.Sprintf(GetLocalizedString("shortBodyLoginAlert", account.Language), ticket.IpAddress),
Metadata: datatypes.JSONMap{
"ip_address": ticket.IpAddress,
"created_at": ticket.CreatedAt,