From 5beeeb958bb689a9d58d79f337e3182d5d1943b9 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sun, 18 Jun 2023 12:27:18 +0100 Subject: [PATCH] userpage: show expiry --- api-userpage.go | 2 +- html/user.html | 9 ++-- lang.go | 8 ++-- lang/admin/da-dk.json | 1 - lang/admin/de-de.json | 1 - lang/admin/el-gr.json | 1 - lang/admin/en-gb.json | 1 - lang/admin/en-us.json | 1 - lang/admin/es-es.json | 1 - lang/admin/fr-fr.json | 1 - lang/admin/hu-hu.json | 1 - lang/admin/nl-nl.json | 1 - lang/admin/pl-pl.json | 1 - lang/admin/pt-br.json | 1 - lang/admin/sv-se.json | 1 - lang/admin/vi-vn.json | 1 - lang/admin/zh-hans.json | 1 - lang/admin/zh-hant.json | 1 - lang/common/ar-aa.json | 3 +- lang/common/da-dk.json | 6 ++- lang/common/de-de.json | 6 ++- lang/common/el-gr.json | 6 ++- lang/common/en-gb.json | 6 ++- lang/common/en-us.json | 21 ++++++++- lang/common/es-es.json | 6 ++- lang/common/fa-ir.json | 3 +- lang/common/fr-fr.json | 6 ++- lang/common/hu-hu.json | 6 ++- lang/common/id-id.json | 3 +- lang/common/it-it.json | 3 +- lang/common/nl-nl.json | 6 ++- lang/common/pl-pl.json | 6 ++- lang/common/pt-br.json | 6 ++- lang/common/ro-ro.json | 3 +- lang/common/sl-si.json | 3 +- lang/common/sv-se.json | 6 ++- lang/common/vi-vn.json | 6 ++- lang/common/zh-hans.json | 6 ++- lang/common/zh-hant.json | 6 ++- scripts/langmover/common.json | 52 +++++++++++++++++++++ storage.go | 24 ++++++++++ ts/user.ts | 87 +++++++++++++++++++++++++++++++++-- 42 files changed, 258 insertions(+), 62 deletions(-) create mode 100644 scripts/langmover/common.json diff --git a/api-userpage.go b/api-userpage.go index fd49c27..4592b90 100644 --- a/api-userpage.go +++ b/api-userpage.go @@ -33,7 +33,7 @@ func (app *appContext) MyDetails(gc *gin.Context) { if emailEnabled { resp.Email = &MyDetailsContactMethodsDTO{} - if email, ok := app.storage.emails[user.ID]; ok { + if email, ok := app.storage.emails[user.ID]; ok && email.Addr != "" { resp.Email.Value = email.Addr resp.Email.Enabled = email.Contact } diff --git a/html/user.html b/html/user.html index 68acc52..60488e5 100644 --- a/html/user.html +++ b/html/user.html @@ -44,13 +44,16 @@ {{ template "login-modal.html" . }}
- +
-
+
+ {{ .strings.expiry }} + +
- {{ .strings.contactMethods }} + {{ .strings.contactMethods }}
diff --git a/lang.go b/lang.go index 1cf3fcd..f3fbe4b 100644 --- a/lang.go +++ b/lang.go @@ -26,9 +26,10 @@ func (ls *adminLangs) getOptions() [][2]string { type commonLangs map[string]commonLang type commonLang struct { - Meta langMeta `json:"meta"` - Strings langSection `json:"strings"` - Notifications langSection `json:"notifications"` + Meta langMeta `json:"meta"` + Strings langSection `json:"strings"` + Notifications langSection `json:"notifications"` + QuantityStrings map[string]quantityString `json:"quantityStrings"` } type adminLang struct { @@ -58,6 +59,7 @@ type userLang struct { notificationsJSON string ValidationStrings map[string]quantityString `json:"validationStrings"` validationStringsJSON string + QuantityStrings map[string]quantityString `json:"quantityStrings"` JSON string } diff --git a/lang/admin/da-dk.json b/lang/admin/da-dk.json index 9170563..ce1de62 100644 --- a/lang/admin/da-dk.json +++ b/lang/admin/da-dk.json @@ -30,7 +30,6 @@ "lastActiveTime": "Sidst Aktiv", "from": "Fra", "user": "Bruger", - "expiry": "Udløb", "userExpiry": "Brugerens Udløb", "userExpiryDescription": "En specificeret tid efter hver tilmelding, sletter/deaktiverer jfa-go kontoen. Du kan ændre denne adfærd i indstillingerne.", "aboutProgram": "Om", diff --git a/lang/admin/de-de.json b/lang/admin/de-de.json index 4b59b80..1c4de83 100644 --- a/lang/admin/de-de.json +++ b/lang/admin/de-de.json @@ -81,7 +81,6 @@ "download": "Herunterladen", "update": "Aktualisieren", "updates": "Aktualisierungen", - "expiry": "Ablaufdatum", "extendExpiry": "Ablaufdatum verlängern", "donate": "Spenden", "conditionals": "Bedingungen", diff --git a/lang/admin/el-gr.json b/lang/admin/el-gr.json index 3700829..3b97023 100644 --- a/lang/admin/el-gr.json +++ b/lang/admin/el-gr.json @@ -75,7 +75,6 @@ "download": "Λήψη", "search": "Αναζήτηση", "inviteDuration": "Διάρκεια Πρόσκλησης", - "expiry": "Λήξη", "userExpiry": "Λήξη Χρήστη", "userExpiryDescription": "Μετά απο ένα καθορισμένο χρόνο μετά απο κάθε εγγραφή, το jfa-go θα διαγράφει/απενεργοποιεί τον λογαριασμό. Μπορείτε να αλλάξετε αυτή την συμπεριφορά στις ρυθμίσεις.", "announce": "Ανακοίνωση", diff --git a/lang/admin/en-gb.json b/lang/admin/en-gb.json index 2597713..01cca19 100644 --- a/lang/admin/en-gb.json +++ b/lang/admin/en-gb.json @@ -71,7 +71,6 @@ "apply": "Apply", "delete": "Delete", "updates": "Updates", - "expiry": "Expiry", "variables": "Variables", "preview": "Preview", "markdownSupported": "Markdown is supported.", diff --git a/lang/admin/en-us.json b/lang/admin/en-us.json index 911ae84..7174ea8 100644 --- a/lang/admin/en-us.json +++ b/lang/admin/en-us.json @@ -33,7 +33,6 @@ "after": "After", "before": "Before", "user": "User", - "expiry": "Expiry", "userExpiry": "User Expiry", "userExpiryDescription": "A specified amount of time after each signup, jfa-go will delete/disable the account. You can change this behaviour in settings.", "aboutProgram": "About", diff --git a/lang/admin/es-es.json b/lang/admin/es-es.json index de45bb2..3a57fb3 100644 --- a/lang/admin/es-es.json +++ b/lang/admin/es-es.json @@ -28,7 +28,6 @@ "lastActiveTime": "Último activo", "from": "De", "user": "Usuario", - "expiry": "Expiración", "userExpiry": "Caducidad del usuario", "userExpiryDescription": "Una cantidad de tiempo específica después de cada registro, jfa-go eliminará / deshabilitará la cuenta. Puede cambiar este comportamiento en la configuración.", "aboutProgram": "Acerca de", diff --git a/lang/admin/fr-fr.json b/lang/admin/fr-fr.json index 9f57f7c..c7937d0 100644 --- a/lang/admin/fr-fr.json +++ b/lang/admin/fr-fr.json @@ -76,7 +76,6 @@ "edit": "Éditer", "customizeMessages": "Personnaliser les e-mails", "inviteDuration": "Durée de l'invitation", - "expiry": "Expiration", "advancedSettings": "Paramètres avancés", "userExpiry": "Expiration de l'utilisateur", "updates": "Mises à jour", diff --git a/lang/admin/hu-hu.json b/lang/admin/hu-hu.json index 3f83575..d6e5470 100644 --- a/lang/admin/hu-hu.json +++ b/lang/admin/hu-hu.json @@ -31,7 +31,6 @@ "lastActiveTime": "Utoljára aktív", "from": "Feladó", "user": "Felhasználó", - "expiry": "Lejárat", "userExpiry": "Felhasználói lejárat", "userExpiryDescription": "Egy meghatározott idő után minden regisztrációt töröl, vagy felfüggeszt a jfa-go. Ezt a működést megváltoztathatod a beállításokban.", "aboutProgram": "Névjegy", diff --git a/lang/admin/nl-nl.json b/lang/admin/nl-nl.json index 62b859a..910202c 100644 --- a/lang/admin/nl-nl.json +++ b/lang/admin/nl-nl.json @@ -75,7 +75,6 @@ "customizeMessages": "E-mails aanpassen", "inviteDuration": "Geldigheidsduur uitnodiging", "userExpiryDescription": "Een bepaalde tijd na elke aanmelding, wordt de account verwijderd/uitgeschakeld door jfa-go. Dit kan aangepast worden in de instellingen.", - "expiry": "Verloop", "userExpiry": "Gebruikersverloop", "extendExpiry": "Verleng verloop", "updates": "Updates", diff --git a/lang/admin/pl-pl.json b/lang/admin/pl-pl.json index e229017..b3957de 100644 --- a/lang/admin/pl-pl.json +++ b/lang/admin/pl-pl.json @@ -31,7 +31,6 @@ "lastActiveTime": "Ostatnia aktywność", "from": "Od", "user": "Użytkownik", - "expiry": "Wygasa", "userExpiry": "Użytkownik wygasa", "userExpiryDescription": "", "aboutProgram": "O", diff --git a/lang/admin/pt-br.json b/lang/admin/pt-br.json index 5b4149d..f84c2b9 100644 --- a/lang/admin/pt-br.json +++ b/lang/admin/pt-br.json @@ -75,7 +75,6 @@ "customizeMessages": "Customizar Emails", "userExpiryDescription": "Após um determinado período de tempo de cada inscrição, o jfa-go apagará/desabilitará a conta. Você pode alterar essa opção nas configurações.", "inviteDuration": "Duração do Convite", - "expiry": "Expira", "userExpiry": "Vencimento do Usuário", "extendExpiry": "Extender o vencimento", "updates": "Atualizações", diff --git a/lang/admin/sv-se.json b/lang/admin/sv-se.json index f16995f..f57d37e 100644 --- a/lang/admin/sv-se.json +++ b/lang/admin/sv-se.json @@ -74,7 +74,6 @@ "notifyInviteExpiry": "Vid utgång", "notifyUserCreation": "Vid användarskapande", "inviteDuration": "Varaktighet för inbjudan", - "expiry": "Löper ut", "userExpiry": "Användarutgång", "userExpiryDescription": "Efter en angiven tid efter varje registrering så tar jfa-go bort/inaktiverar kontot. Du kan ändra detta beteende i inställningarna.", "extendExpiry": "Förläng utgång" diff --git a/lang/admin/vi-vn.json b/lang/admin/vi-vn.json index 358e1cb..cb058f4 100644 --- a/lang/admin/vi-vn.json +++ b/lang/admin/vi-vn.json @@ -31,7 +31,6 @@ "lastActiveTime": "Lần cuối Hoạt động", "from": "Từ", "user": "Người dùng", - "expiry": "Hết hạn", "userExpiry": "Hết hạn Người dùng", "userExpiryDescription": "Sau một khoảng thời gian nhất định sau khi mỗi đăng ký, jfa-go sẽ xóa/vô hiệu hóa tài khoản. Bạn có thể chỉnh sửa chế độ này trong cài đặt.", "aboutProgram": "Thông tin", diff --git a/lang/admin/zh-hans.json b/lang/admin/zh-hans.json index cbe051e..97561a2 100644 --- a/lang/admin/zh-hans.json +++ b/lang/admin/zh-hans.json @@ -30,7 +30,6 @@ "lastActiveTime": "上次活动", "from": "从", "user": "用户", - "expiry": "到期", "userExpiry": "用户到期", "userExpiryDescription": "每次注册后的指定时间,jfa-go 将删除/禁用该帐户。您可以在设置中更改此行为。", "aboutProgram": "关于", diff --git a/lang/admin/zh-hant.json b/lang/admin/zh-hant.json index c4d24d4..a4b318f 100644 --- a/lang/admin/zh-hant.json +++ b/lang/admin/zh-hant.json @@ -31,7 +31,6 @@ "lastActiveTime": "上次啟用時間", "from": "從", "user": "帳戶", - "expiry": "到期", "userExpiry": "帳戶到期", "userExpiryDescription": "每次註冊后指定的時間,jfa-go 將刪除/禁用該帳戶。您可以在設定中更改此行為。", "aboutProgram": "關於", diff --git a/lang/common/ar-aa.json b/lang/common/ar-aa.json index b472463..6d8988a 100644 --- a/lang/common/ar-aa.json +++ b/lang/common/ar-aa.json @@ -3,5 +3,6 @@ "name": "العربية (AR)" }, "strings": {}, - "notifications": {} + "notifications": {}, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/da-dk.json b/lang/common/da-dk.json index 8a89fd6..8155ca8 100644 --- a/lang/common/da-dk.json +++ b/lang/common/da-dk.json @@ -31,7 +31,8 @@ "enabled": "Aktiveret", "disabled": "Deaktiveret", "reEnable": "Genaktiver", - "disable": "Deaktiver" + "disable": "Deaktiver", + "expiry": "Udløb" }, "notifications": { "errorLoginBlank": "Brugernavnet og/eller adgangskoden blev efterladt tomme.", @@ -39,5 +40,6 @@ "errorUnknown": "Ukendt fejl.", "error401Unauthorized": "Adgang nægtet. Prøv at genindlæse siden.", "errorSaveSettings": "Kunne ikke gemme indstillingerne." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/de-de.json b/lang/common/de-de.json index da17b61..9b10ccd 100644 --- a/lang/common/de-de.json +++ b/lang/common/de-de.json @@ -31,7 +31,8 @@ "enabled": "Aktiviert", "disabled": "Deaktiviert", "reEnable": "Wieder aktivieren", - "disable": "Deaktivieren" + "disable": "Deaktivieren", + "expiry": "Ablaufdatum" }, "notifications": { "errorLoginBlank": "Der Benutzername und/oder das Passwort wurden nicht ausgefüllt.", @@ -39,5 +40,6 @@ "errorUnknown": "Unbekannter Fehler.", "error401Unauthorized": "Unberechtigt. Versuch, die Seite zu aktualisieren.", "errorSaveSettings": "Einstellungen konnten nicht gespeichert werden." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/el-gr.json b/lang/common/el-gr.json index 33031b9..1a1a0d6 100644 --- a/lang/common/el-gr.json +++ b/lang/common/el-gr.json @@ -22,7 +22,8 @@ "enabled": "Ενεργοποιημένο", "disabled": "Απενεργοποιημένο", "reEnable": "Επανα-ενεργοποίηση", - "disable": "Απενεργοποίηση" + "disable": "Απενεργοποίηση", + "expiry": "Λήξη" }, "notifications": { "errorLoginBlank": "Το όνομα χρήστη και/ή ο κωδικός ήταν κενά.", @@ -30,5 +31,6 @@ "errorUnknown": "Άγνωστο σφάλμα.", "error401Unauthorized": "Ανεξουσιοδότητος. Προσπαθήστε να κάνετε επαναφόρτωση την σελίδα.", "errorSaveSettings": "Αποτυχία αποθήκευσης ρυθμίσεων." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/en-gb.json b/lang/common/en-gb.json index c4451e6..799d4bf 100644 --- a/lang/common/en-gb.json +++ b/lang/common/en-gb.json @@ -31,7 +31,8 @@ "enabled": "Enabled", "disabled": "Disabled", "reEnable": "Re-enable", - "disable": "Disable" + "disable": "Disable", + "expiry": "Expiry" }, "notifications": { "errorLoginBlank": "The username and/or password was left blank.", @@ -39,5 +40,6 @@ "errorUnknown": "Unknown error.", "error401Unauthorized": "Unauthorised. Try refreshing the page.", "errorSaveSettings": "Couldn't save settings." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/en-us.json b/lang/common/en-us.json index b8bb943..de53a29 100644 --- a/lang/common/en-us.json +++ b/lang/common/en-us.json @@ -32,7 +32,10 @@ "disabled": "Disabled", "reEnable": "Re-enable", "disable": "Disable", - "contactMethods": "Contact Methods" + "contactMethods": "Contact Methods", + "accountStatus": "Account Status", + "notSet": "Not set", + "expiry": "Expiry" }, "notifications": { "errorLoginBlank": "The username and/or password were left blank.", @@ -40,5 +43,19 @@ "errorUnknown": "Unknown error.", "error401Unauthorized": "Unauthorized. Try refreshing the page.", "errorSaveSettings": "Couldn't save settings." + }, + "quantityStrings": { + "year": { + "singular": "{n} Year", + "plural": "{n} Years" + }, + "month": { + "singular": "{n} Month", + "plural": "{n} Months" + }, + "day": { + "singular": "{n} Day", + "plural": "{n} Days" + } } -} +} \ No newline at end of file diff --git a/lang/common/es-es.json b/lang/common/es-es.json index fdc7cde..261b22e 100644 --- a/lang/common/es-es.json +++ b/lang/common/es-es.json @@ -31,7 +31,8 @@ "enabled": "Activado", "disabled": "Desactivado", "reEnable": "Reactivar", - "disable": "Desactivar" + "disable": "Desactivar", + "expiry": "Expiración" }, "notifications": { "errorLoginBlank": "El nombre de usuario y/o la contraseña se dejaron en blanco.", @@ -39,5 +40,6 @@ "errorUnknown": "Error desconocido.", "error401Unauthorized": "No autorizado. Intente actualizar la página.", "errorSaveSettings": "No se pudo guardar la configuración." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/fa-ir.json b/lang/common/fa-ir.json index 612fc27..cc096c5 100644 --- a/lang/common/fa-ir.json +++ b/lang/common/fa-ir.json @@ -24,5 +24,6 @@ "contactDiscord": "از طریق دیسکورد تماس بگیرید", "theme": "موضوع" }, - "notifications": {} + "notifications": {}, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/fr-fr.json b/lang/common/fr-fr.json index c97561d..9a31d3d 100644 --- a/lang/common/fr-fr.json +++ b/lang/common/fr-fr.json @@ -31,7 +31,8 @@ "enabled": "Activé", "disabled": "Désactivé", "reEnable": "Ré-activé", - "disable": "Désactivé" + "disable": "Désactivé", + "expiry": "Expiration" }, "notifications": { "errorLoginBlank": "Le nom d'utilisateur et/ou le mot de passe sont vides.", @@ -39,5 +40,6 @@ "errorUnknown": "Erreur inconnue.", "error401Unauthorized": "Non autorisé. Essayez d'actualiser la page.", "errorSaveSettings": "Impossible d'enregistrer les paramètres." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/hu-hu.json b/lang/common/hu-hu.json index 0c934a4..367dcec 100644 --- a/lang/common/hu-hu.json +++ b/lang/common/hu-hu.json @@ -9,7 +9,9 @@ "enabled": "Engedélyezve", "disabled": "Tiltva", "reEnable": "Újra engedélyezés", - "disable": "Letiltás" + "disable": "Letiltás", + "expiry": "Lejárat" }, - "notifications": {} + "notifications": {}, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/id-id.json b/lang/common/id-id.json index 8c5f511..b517b8d 100644 --- a/lang/common/id-id.json +++ b/lang/common/id-id.json @@ -25,5 +25,6 @@ "errorUnknown": "Kesalahan yang tidak diketahui.", "error401Unauthorized": "Tidak ter-otorisasi. Coba segarkan halaman.", "errorSaveSettings": "Tidak dapat menyimpan pengaturan." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/it-it.json b/lang/common/it-it.json index 1576a7b..452585f 100644 --- a/lang/common/it-it.json +++ b/lang/common/it-it.json @@ -26,5 +26,6 @@ "refresh": "Aggiorna", "required": "Richiesto" }, - "notifications": {} + "notifications": {}, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/nl-nl.json b/lang/common/nl-nl.json index 3ba8c08..9dbddee 100644 --- a/lang/common/nl-nl.json +++ b/lang/common/nl-nl.json @@ -31,7 +31,8 @@ "enabled": "Ingeschakeld", "disabled": "Uitgeschakeld", "reEnable": "Opnieuw inschakelen", - "disable": "Uitschakelen" + "disable": "Uitschakelen", + "expiry": "Verloop" }, "notifications": { "errorLoginBlank": "De gebruikersnaam en/of wachtwoord is leeg.", @@ -39,5 +40,6 @@ "errorUnknown": "Onbekende fout.", "error401Unauthorized": "Geen toegang. Probeer de pagina te vernieuwen.", "errorSaveSettings": "Opslaan van instellingen mislukt." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/pl-pl.json b/lang/common/pl-pl.json index 530fda0..8d042fa 100644 --- a/lang/common/pl-pl.json +++ b/lang/common/pl-pl.json @@ -28,11 +28,13 @@ "admin": "Admin", "enabled": "Włączone", "disabled": "Wyłączone", - "disable": "Wyłączone" + "disable": "Wyłączone", + "expiry": "Wygasa" }, "notifications": { "errorConnection": "Nie udało się połączyć z jfa-go.", "errorUnknown": "Nieznany błąd.", "error401Unauthorized": "Nieautoryzowany. Spróbuj odświeżyć stronę." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/pt-br.json b/lang/common/pt-br.json index 16a0bae..e4f6191 100644 --- a/lang/common/pt-br.json +++ b/lang/common/pt-br.json @@ -31,7 +31,8 @@ "enabled": "Habilitado", "disabled": "Desativado", "reEnable": "Reativar", - "disable": "Desativar" + "disable": "Desativar", + "expiry": "Expira" }, "notifications": { "errorLoginBlank": "O nome de usuário e/ou senha foram deixados em branco.", @@ -39,5 +40,6 @@ "errorUnknown": "Erro desconhecido.", "error401Unauthorized": "Não autorizado. Tente atualizar a página.", "errorSaveSettings": "Não foi possível salvar as configurações." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/ro-ro.json b/lang/common/ro-ro.json index 8bf759e..3571c19 100644 --- a/lang/common/ro-ro.json +++ b/lang/common/ro-ro.json @@ -3,5 +3,6 @@ "name": "Română (ROU)" }, "strings": {}, - "notifications": {} + "notifications": {}, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/sl-si.json b/lang/common/sl-si.json index 5980f6a..d99631b 100644 --- a/lang/common/sl-si.json +++ b/lang/common/sl-si.json @@ -26,5 +26,6 @@ "refresh": "Osveži", "required": "Obvezno" }, - "notifications": {} + "notifications": {}, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/sv-se.json b/lang/common/sv-se.json index 674198f..25d5962 100644 --- a/lang/common/sv-se.json +++ b/lang/common/sv-se.json @@ -19,7 +19,8 @@ "logout": "Logga ut", "admin": "Admin", "enabled": "Aktiverad", - "disabled": "Inaktiverad" + "disabled": "Inaktiverad", + "expiry": "Löper ut" }, "notifications": { "errorLoginBlank": "Användarnamnet och/eller lösenordet lämnades tomt.", @@ -27,5 +28,6 @@ "errorUnknown": "Okänt fel.", "error401Unauthorized": "Obehörig. Prova att uppdatera sidan.", "errorSaveSettings": "Det gick inte att spara inställningarna." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/vi-vn.json b/lang/common/vi-vn.json index 6122823..4464173 100644 --- a/lang/common/vi-vn.json +++ b/lang/common/vi-vn.json @@ -9,10 +9,12 @@ "enabled": "Mở", "disabled": "Tắt", "reEnable": "Mở lại", - "disable": "Tắt" + "disable": "Tắt", + "expiry": "Hết hạn" }, "notifications": { "errorConnection": "Không thể kết nối với jfa-go.", "error401Unauthorized": "Không được phép. Hãy thử làm mới trang." - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/zh-hans.json b/lang/common/zh-hans.json index 2f90602..17e7354 100644 --- a/lang/common/zh-hans.json +++ b/lang/common/zh-hans.json @@ -31,7 +31,8 @@ "enabled": "已启用", "disabled": "已禁用", "reEnable": "重新启用", - "disable": "禁用" + "disable": "禁用", + "expiry": "到期" }, "notifications": { "errorLoginBlank": "用户名/密码留空。", @@ -39,5 +40,6 @@ "errorUnknown": "未知错误。", "error401Unauthorized": "无授权。尝试刷新页面。", "errorSaveSettings": "无法保存设置。" - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/lang/common/zh-hant.json b/lang/common/zh-hant.json index 9d69d0d..f82182c 100644 --- a/lang/common/zh-hant.json +++ b/lang/common/zh-hant.json @@ -31,7 +31,8 @@ "enabled": "已啟用", "disabled": "已禁用", "reEnable": "重新啟用", - "disable": "禁用" + "disable": "禁用", + "expiry": "到期" }, "notifications": { "errorLoginBlank": "帳戶名稱和/或密碼留空。", @@ -39,5 +40,6 @@ "errorUnknown": "未知的錯誤。", "error401Unauthorized": "未經授權。嘗試重新整理頁面。", "errorSaveSettings": "無法儲存設置。" - } + }, + "quantityStrings": {} } \ No newline at end of file diff --git a/scripts/langmover/common.json b/scripts/langmover/common.json new file mode 100644 index 0000000..76eb632 --- /dev/null +++ b/scripts/langmover/common.json @@ -0,0 +1,52 @@ +{ + "meta": { + "name": "English (US)" + }, + "strings": { + "username": "common", + "password": "common", + "emailAddress": "common", + "name": "common", + "submit": "common", + "send": "common", + "success": "common", + "continue": "common", + "error": "common", + "copy": "common", + "copied": "common", + "time24h": "common", + "time12h": "common", + "linkTelegram": "common", + "contactEmail": "common", + "contactTelegram": "common", + "linkDiscord": "common", + "linkMatrix": "common", + "contactDiscord": "common", + "theme": "common", + "refresh": "common", + "required": "common", + "login": "common", + "logout": "common", + "admin": "common", + "enabled": "common", + "disabled": "common", + "reEnable": "common", + "disable": "common", + "contactMethods": "common", + "accountStatus": "common", + "notSet": "common", + "expiry": "admin" + }, + "notifications": { + "errorLoginBlank": "common", + "errorConnection": "common", + "errorUnknown": "common", + "error401Unauthorized": "common", + "errorSaveSettings": "common" + }, + "quantityStrings": { + "year": "common", + "month": "common", + "day": "common" + } +} diff --git a/storage.go b/storage.go index 16d179c..38d76c7 100644 --- a/storage.go +++ b/storage.go @@ -202,6 +202,25 @@ func (common *commonLangs) patchCommonNotifications(to *langSection, from ...str } } +func (common *commonLangs) patchCommonQuantityStrings(to *map[string]quantityString, from ...string) { + if *to == nil { + *to = map[string]quantityString{} + } + for n, ev := range (*common)[from[len(from)-1]].QuantityStrings { + if v, ok := (*to)[n]; !ok || (v.Singular == "" && v.Plural == "") { + i := 0 + for i < len(from)-1 { + ev, ok = (*common)[from[i]].QuantityStrings[n] + if ok && ev.Singular != "" && ev.Plural != "" { + break + } + i++ + } + (*to)[n] = ev + } + } +} + func patchLang(to *langSection, from ...*langSection) { if *to == nil { *to = langSection{} @@ -283,10 +302,14 @@ func (st *Storage) loadLangCommon(filesystems ...fs.FS) error { if err == nil { loadedLangs[fsIndex][lang.Meta.Fallback+".json"] = true patchLang(&lang.Strings, &fallback.Strings, &english.Strings) + patchLang(&lang.Notifications, &fallback.Notifications, &english.Notifications) + patchQuantityStrings(&lang.QuantityStrings, &fallback.QuantityStrings, &english.QuantityStrings) } } if (lang.Meta.Fallback != "" && err != nil) || lang.Meta.Fallback == "" { patchLang(&lang.Strings, &english.Strings) + patchLang(&lang.Notifications, &english.Notifications) + patchQuantityStrings(&lang.QuantityStrings, &english.QuantityStrings) } } st.lang.Common[index] = lang @@ -437,6 +460,7 @@ func (st *Storage) loadLangUser(filesystems ...fs.FS) error { } st.lang.Common.patchCommonStrings(&lang.Strings, index) st.lang.Common.patchCommonNotifications(&lang.Notifications, index) + st.lang.Common.patchCommonQuantityStrings(&lang.QuantityStrings, index) // turns out, a lot of email strings are useful on the user page. emailLang := []langSection{st.lang.Email[index].WelcomeEmail, st.lang.Email[index].UserDisabled, st.lang.Email[index].UserExpired} for _, v := range emailLang { diff --git a/ts/user.ts b/ts/user.ts index 68af79c..ca526e4 100644 --- a/ts/user.ts +++ b/ts/user.ts @@ -1,7 +1,7 @@ import { ThemeManager } from "./modules/theme.js"; import { lang, LangFile, loadLangSelector } from "./modules/lang.js"; import { Modal } from "./modules/modal.js"; -import { _get, _post, notificationBox, whichAnimationEvent } from "./modules/common.js"; +import { _get, _post, notificationBox, whichAnimationEvent, toDateString } from "./modules/common.js"; import { Login } from "./modules/login.js"; interface userWindow extends Window { @@ -31,6 +31,7 @@ window.notifications = new notificationBox(document.getElementById('notification var rootCard = document.getElementById("card-user"); var contactCard = document.getElementById("card-contact"); +var statusCard = document.getElementById("card-status"); interface MyDetailsContactMethod { value: string; @@ -58,15 +59,17 @@ interface ContactDTO { class ContactMethods { private _card: HTMLElement; + private _content: HTMLElement; private _buttons: { [name: string]: { element: HTMLElement, details: MyDetailsContactMethod } }; constructor (card: HTMLElement) { this._card = card; + this._content = this._card.querySelector(".content"); this._buttons = {}; } clear = () => { - this._card.textContent = ""; + this._content.textContent = ""; this._buttons = {}; } @@ -80,7 +83,7 @@ class ContactMethods { ${icon} - ${details.value} + ${(details.value == "") ? window.lang.strings("notSet") : details.value}