From 3d5bea003ab5f3153969f36f0baa612f11816e1d Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 14 Jan 2021 20:24:28 +0000 Subject: [PATCH] Fix email language selection, add finished french emails --- api.go | 27 +++++++++++++++++++++++---- lang/email/fr-fr.json | 10 ++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/api.go b/api.go index f65a0c9..d1c382b 100644 --- a/api.go +++ b/api.go @@ -1087,7 +1087,7 @@ func (app *appContext) GetConfig(gc *gin.Context) { // Load language options loadLangs := func(langs *map[string]map[string]interface{}, settingsKey string) (string, []string) { langOptions := make([]string, len(*langs)) - chosenLang := app.config.Section("ui").Key("language-" + settingsKey).MustString("en-us") + chosenLang := app.config.Section("ui").Key("language" + settingsKey).MustString("en-us") chosenLangName := (*langs)[chosenLang]["meta"].(map[string]interface{})["name"].(string) i := 0 for _, lang := range *langs { @@ -1096,14 +1096,25 @@ func (app *appContext) GetConfig(gc *gin.Context) { } return chosenLangName, langOptions } - formChosen, formOptions := loadLangs(&app.storage.lang.Form, "form") + formChosen, formOptions := loadLangs(&app.storage.lang.Form, "-form") fl := resp.Sections["ui"].Settings["language-form"] fl.Options = formOptions fl.Value = formChosen - adminChosen, adminOptions := loadLangs(&app.storage.lang.Admin, "admin") + adminChosen, adminOptions := loadLangs(&app.storage.lang.Admin, "-admin") al := resp.Sections["ui"].Settings["language-admin"] al.Options = adminOptions al.Value = adminChosen + emailOptions := make([]string, len(app.storage.lang.Email)) + chosenLang := app.config.Section("email").Key("language").MustString("en-us") + emailChosen := app.storage.lang.Email.get(chosenLang, "meta", "name") + i := 0 + for langName := range app.storage.lang.Email { + emailOptions[i] = app.storage.lang.Email.get(langName, "meta", "name") + i++ + } + el := resp.Sections["email"].Settings["language"] + el.Options = emailOptions + el.Value = emailChosen for sectName, section := range resp.Sections { for settingName, setting := range section.Settings { val := app.config.Section(sectName).Key(settingName) @@ -1121,10 +1132,11 @@ func (app *appContext) GetConfig(gc *gin.Context) { } resp.Sections["ui"].Settings["language-form"] = fl resp.Sections["ui"].Settings["language-admin"] = al + resp.Sections["email"].Settings["language"] = el t := resp.Sections["jellyfin"].Settings["type"] opts := make([]string, len(serverTypes)) - i := 0 + i = 0 for _, v := range serverTypes { opts[i] = v i++ @@ -1169,6 +1181,13 @@ func (app *appContext) ModifyConfig(gc *gin.Context) { break } } + } else if section == "email" && setting == "language" { + for key := range app.storage.lang.Email { + if app.storage.lang.Email.get(key, "meta", "name") == value.(string) { + tempConfig.Section("email").Key("language").SetValue(key) + break + } + } } else if section == "jellyfin" && setting == "type" { for k, v := range serverTypes { if v == value.(string) { diff --git a/lang/email/fr-fr.json b/lang/email/fr-fr.json index 40e7adf..54850bf 100644 --- a/lang/email/fr-fr.json +++ b/lang/email/fr-fr.json @@ -4,13 +4,21 @@ "author": "https://github.com/Cornichon420" }, "userCreated": { + "title": "Notification : Utilisateur créé", "aUserWasCreated": "Un utilisateur a été créé avec ce code {n}", "name": "Nom", "emailAddress": "Adresse", "time": "Date", "notificationNotice": "" }, + "inviteExpiry": { + "title": "Notification : Invitation expirée", + "inviteExpired": "Invitation expirée.", + "expiredAt": "Le code {n} a expiré à {n}.", + "notificationNotice": "" + }, "passwordReset": { + "title": "Réinitialisation de mot de passe demandée - Jellyfin", "helloUser": "Salut {n},", "someoneHasRequestedReset": "Quelqu'un vient de demander une réinitialisation du mot de passe via Jellyfin.", "ifItWasYou": "Si c'était bien toi, renseigne le code PIN en dessous.", @@ -19,10 +27,12 @@ "pin": "PIN" }, "userDeleted": { + "title": "Ton compte a été désactivé - Jellyfin", "yourAccountWasDeleted": "Ton compte Jellyfin a été supprimé.", "reason": "Motif" }, "inviteEmail": { + "title": "Invitation - Jellyfin", "hello": "Salut", "youHaveBeenInvited": "Tu a été invité à rejoindre Jellyfin.", "toJoin": "Pour continuer, suis le lien en dessous.",