From 37fad48ec85bc36a921ad211c4ae4c893a33948a Mon Sep 17 00:00:00 2001 From: Athozus Date: Sun, 16 Jul 2023 19:42:08 +0200 Subject: [PATCH] Add a tooltip for elapsed time since the delivery It adds the file util/time_ago.lua in order to re-use the function further --- init.lua | 1 + locale/mail.de.tr | 44 ++++++++++++++++++++++++++------------------ locale/mail.es.tr | 44 ++++++++++++++++++++++++++------------------ locale/mail.fr.tr | 44 ++++++++++++++++++++++++++------------------ locale/mail.hu.tr | 44 ++++++++++++++++++++++++++------------------ locale/mail.pt_BR.tr | 44 ++++++++++++++++++++++++++------------------ locale/mail.zh_CN.tr | 44 ++++++++++++++++++++++++++------------------ locale/mail.zh_TW.tr | 44 ++++++++++++++++++++++++++------------------ locale/template.txt | 44 ++++++++++++++++++++++++++------------------ ui/message.lua | 1 + util/time_ago.lua | 29 +++++++++++++++++++++++++++++ 11 files changed, 239 insertions(+), 144 deletions(-) create mode 100644 util/time_ago.lua diff --git a/init.lua b/init.lua index 23f41f4..143b86f 100644 --- a/init.lua +++ b/init.lua @@ -62,6 +62,7 @@ local MP = minetest.get_modpath(minetest.get_current_modname()) dofile(MP .. "/util/normalize.lua") dofile(MP .. "/util/contact.lua") dofile(MP .. "/util/uuid.lua") +dofile(MP .. "/util/time_ago.lua") dofile(MP .. "/chatcommands.lua") dofile(MP .. "/migrate.lua") dofile(MP .. "/hud.lua") diff --git a/locale/mail.de.tr b/locale/mail.de.tr index 903f9e4..aac06a1 100644 --- a/locale/mail.de.tr +++ b/locale/mail.de.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)=Expat (Code), WTFPL (Texturen) Communication using this system is NOT guaranteed to be private!=Die Kommunikation über dieses System ist NICHT garantiert privat! Admins are able to view the messages of any player.=Admins können die Nachrichten aller Spieler sehen. Contributors=Mitwirkende -Settings=Einstellungen -About=Über You have a new message from @1! Subject: @2=Sie haben eine neue Nachricht von @1! Betreff: @2 To view it, type /mail=Geben Sie zum Anzeigen „/mail“ ein You could also use the button in your inventory.=Sie können auch die Schaltfläche in Ihrem Inventar verwenden. @@ -17,18 +15,26 @@ Save draft=Entwurf speichern Send=Senden CC=CC No contacts=Keine Kontakte +Edit=Bearbeiten +Name=Name No drafts=Keine Entwürfe Player name=Spielername That name is already in your contacts=Dieser Name ist bereits in Ihren Kontakten The contact name cannot be empty.=Der Kontaktname kann nicht leer sein. +Note=Anmerkung +Back=Zurück Maillist name=Verteilerlistenname Desc=Beschreibung Players=Spieler That name is already in your mailing lists.=Dieser Name ist bereits in Ihren Verteilerlisten. The mailing list name cannot be empty.=Der Verteilerlistenname kann nicht leer sein. -Save=Speichern Mark Read=Als gelesen makieren Mark Unread=Als ungelesen makieren +From=Von +(No description)=(Keine Beschreibung) +No maillist=Keine Verteilerliste +Receivers=Empfänger +You have mail! Type /mail to read=Sie haben Post! „/mail“ eingeben zum Lesen Filter=Filter Allow multiple selection=Mehrfachauswahl zulassen @1 of @2 selected=@1 von @2 ausgewählt @@ -37,8 +43,8 @@ No mail=Keine Nachrichten Reply=Antworten Reply all=Allen antworten Forward=Weiterleiten -Ascending=Aufsteigend -Descending=Absteigend +Date=Datum +Subject=Betreff Read=Lesen Trash=Papierkorb Inbox=Posteingang @@ -49,20 +55,11 @@ Mail lists=Verteilerlisten Options=Einstellungen Close=Schließen (No subject)=(Kein Betreff) -(No description)=(Keine Beschreibung) -No maillist=Keine Verteilerliste -Note=Anmerkung -Edit=Bearbeiten -Name=Name -Back=Zurück -Delete=Löschen New=Neu -Receivers=Empfänger -You have mail! Type /mail to read=Sie haben Post! „/mail“ eingeben zum Lesen -Subject=Betreff -From=Von +Delete=Löschen To=An -Date=Datum +Ascending=Aufsteigend +Descending=Absteigend Add=Hinzufügen Remove=Entfernen Notifications=Benachrichtigungen @@ -77,7 +74,18 @@ Default sorting fields=Standardsortierfelder Other=Anderes Move deleted messages to trash=Gelöschte Nachrichten in den Papierkorb verschieben Reset=Zurücksetzen +Settings=Einstellungen +About=Über +Save=Speichern +From/To=Von/An +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore=Wiederherstellen Empty=Leer Trash is empty=Papierkorb ist leer -From/To=Von/An diff --git a/locale/mail.es.tr b/locale/mail.es.tr index 0544776..db5f126 100644 --- a/locale/mail.es.tr +++ b/locale/mail.es.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)= Communication using this system is NOT guaranteed to be private!= Admins are able to view the messages of any player.= Contributors= -Settings= -About=Acerca de You have a new message from @1! Subject: @2= To view it, type /mail= You could also use the button in your inventory.= @@ -17,18 +15,26 @@ Save draft=Guardar borrador Send=Enviar CC=CC No contacts= +Edit=Editar +Name=Nombre No drafts=No hay borradores Player name=Nombre del jugador That name is already in your contacts=Ese nombre ya está en tus contactos The contact name cannot be empty.=Ese nombre de contacto no puede estar vacío. +Note=Nota +Back=Volver Maillist name=Nombre de la lista de correo Desc=Desc Players=Jugadores That name is already in your mailing lists.=Ese nombre ya está entus listas de correo. The mailing list name cannot be empty.=Ese nombre de lista de correo no puede estar vacío. -Save=Guardar Mark Read=Marcar como leído Mark Unread=Marcar como no leído +From=De +(No description)=(Sin descripción) +No maillist=Sin lista de correo +Receivers= +You have mail! Type /mail to read= Filter=Filtrar Allow multiple selection=Permitir selección múltiple @1 of @2 selected= @@ -37,8 +43,8 @@ No mail=Sin correo Reply=Responder Reply all=Responder a todos Forward=Reenviar -Ascending=Ascendente -Descending=Descendiente +Date=Fecha +Subject=Asunto Read=Leído Trash= Inbox=Entrada @@ -49,20 +55,11 @@ Mail lists=Listas de correo Options= Close=Cerrar (No subject)=(Sin asunto) -(No description)=(Sin descripción) -No maillist=Sin lista de correo -Note=Nota -Edit=Editar -Name=Nombre -Back=Volver -Delete=Borrar New=Nuevo -Receivers= -You have mail! Type /mail to read= -Subject=Asunto -From=De +Delete=Borrar To=Para -Date=Fecha +Ascending=Ascendente +Descending=Descendiente Add=Añadir Remove=Quitar Notifications= @@ -77,7 +74,18 @@ Default sorting fields= Other= Move deleted messages to trash= Reset= +Settings= +About=Acerca de +Save=Guardar +From/To=De/Para +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore= Empty= Trash is empty= -From/To=De/Para diff --git a/locale/mail.fr.tr b/locale/mail.fr.tr index 4baa600..9eec3d1 100644 --- a/locale/mail.fr.tr +++ b/locale/mail.fr.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)=Expat (code), WTFPL (textures) Communication using this system is NOT guaranteed to be private!=La communication par ce système n'est pas garantie d'être privée ! Admins are able to view the messages of any player.=Les administrateurs peuvent voir les messages de chaque joueur. Contributors=Contributeurs -Settings=Paramètres -About=À propos You have a new message from @1! Subject: @2=Vous avez un nouveau message de @1 ! Objet : @2 To view it, type /mail=Pour le consulter, entrez /mail You could also use the button in your inventory.=Vous pouvez également utiliser le bouton dans votre inventaire @@ -17,18 +15,26 @@ Save draft=Enregistrer le brouillon Send=Envoyer CC=Cc No contacts=Aucun contact +Edit=Modifier +Name=Nom No drafts=Aucun brouillon Player name=Nom du joueur That name is already in your contacts=Ce nom est déjà dans vos contacts The contact name cannot be empty.=Le nom du contact ne peut pas être vide. +Note=Note +Back=Retour Maillist name=Nom de la liste de diffusion Desc=Desc Players=Joueurs That name is already in your mailing lists.=Ce nom est déjà présent dans vos listes de diffusion. The mailing list name cannot be empty.=Le nom de la liste de diffusion ne peut pas être vide. -Save=Sauvegarder Mark Read=Marquer comme lu Mark Unread=Marquer non lu +From=De +(No description)=Sans description +No maillist=Aucune liste de diffusion +Receivers=Destinataires +You have mail! Type /mail to read=Vous avez reçu un mail ! Entrez /mail pour le consulter Filter=Filtre Allow multiple selection=Autoriser la sélection multiple @1 of @2 selected=@1 sur @2 sélectionnés @@ -37,8 +43,8 @@ No mail=Aucun mail Reply=Répondre Reply all=Répondre à tous Forward=Transférer -Ascending=Croissant -Descending=Décroissant +Date=Date +Subject=Objet Read=Lire Trash=Corbeille Inbox=Boîte de réception @@ -49,20 +55,11 @@ Mail lists=Listes de diffusion Options=Options Close=Fermer (No subject)=(Sans objet) -(No description)=Sans description -No maillist=Aucune liste de diffusion -Note=Note -Edit=Modifier -Name=Nom -Back=Retour -Delete=Supprimer New=Nouveau -Receivers= -You have mail! Type /mail to read=Vous avez reçu un mail ! Entrez /mail pour le consulter -Subject=Objet -From=De +Delete=Supprimer To=À -Date=Date +Ascending=Croissant +Descending=Décroissant Add=Ajouter Remove=Enlever Notifications=Notifications @@ -77,7 +74,18 @@ Default sorting fields=Champs de tri par défaut Other=Autre Move deleted messages to trash=Supprimer les messages dans la corbeille Reset=Réinitialiser +Settings=Paramètres +About=À propos +Save=Sauvegarder +From/To=De/À +years=années +months=mois +weeks=semaines +days=jours +hours=heures +minuts=minutes +seconds=secondes +@1 ago=Il y a @1 Restore=Restaurer Empty=Vider Trash is empty=La corbeille est vide -From/To=De/À diff --git a/locale/mail.hu.tr b/locale/mail.hu.tr index 49d7b03..d56279c 100644 --- a/locale/mail.hu.tr +++ b/locale/mail.hu.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)=Expat (kód), WTFPL (textúrák) Communication using this system is NOT guaranteed to be private!=A systemben lévő komunikáció nem garantáltan privát! Admins are able to view the messages of any player.=Az adminok megtudják nézni minden játékos üzenetjét. Contributors=Közreműködöttek -Settings=Beállítások -About=Róla You have a new message from @1! Subject: @2=Van egy új üzeneted @1-től Cím: @2 To view it, type /mail=Ahhoz hogy megnézd, írd /mail You could also use the button in your inventory.=A gombot is tudod használni az inventoridban. @@ -17,18 +15,26 @@ Save draft=mentés piszkozatként Send=Küldés CC=CC No contacts= +Edit=Szerkesztés +Name=Név No drafts=Nincsenek piszkozatok Player name=Játékos neve That name is already in your contacts=A név már a kontaktok között van The contact name cannot be empty.=A contakt neve nem lehet üres. +Note=Jegyzet +Back=Visza Maillist name=Levelező lista neve Desc=Desc Players=Játékosok That name is already in your mailing lists.=A név már benne van a levelező listában The mailing list name cannot be empty.=A levelező lista neve nem lehet üres -Save=Mentés Mark Read=Jelöld olvasottként Mark Unread=Jelöld olvasatlanul +From=Tőle +(No description)=(Nincs leírás) +No maillist=Nincs levelező lista +Receivers= +You have mail! Type /mail to read=Van egy leveled! Írd /mail az olvasáshoz Filter=Filterek Allow multiple selection= @1 of @2 selected= @@ -37,8 +43,8 @@ No mail=Nincs levél Reply=Válasz Reply all=Válaszmindenkinek Forward=Továbbítás -Ascending=Emelkedő -Descending=Sűlyedő +Date=Dátum +Subject=Cím Read=Olvasott Trash= Inbox=PostaLáda @@ -49,20 +55,11 @@ Mail lists=Levelező lista Options=Lehetőségek Close=Bezár (No subject)=(nincs cím) -(No description)=(Nincs leírás) -No maillist=Nincs levelező lista -Note=Jegyzet -Edit=Szerkesztés -Name=Név -Back=Visza -Delete=Törlés New=Új -Receivers= -You have mail! Type /mail to read=Van egy leveled! Írd /mail az olvasáshoz -Subject=Cím -From=Tőle +Delete=Törlés To=Neki -Date=Dátum +Ascending=Emelkedő +Descending=Sűlyedő Add=Hozzáadás Remove=Elvétel Notifications=Értesítések @@ -77,7 +74,18 @@ Default sorting fields=Alap válogató terület Other= Move deleted messages to trash= Reset=Viszaállítás +Settings=Beállítások +About=Róla +Save=Mentés +From/To=Tól(től)/neki +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore= Empty= Trash is empty= -From/To=Tól(től)/neki diff --git a/locale/mail.pt_BR.tr b/locale/mail.pt_BR.tr index 17fda92..01bdc8a 100644 --- a/locale/mail.pt_BR.tr +++ b/locale/mail.pt_BR.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)= Communication using this system is NOT guaranteed to be private!=A comunicação usando este sistema não possui garantia de privacidade Admins are able to view the messages of any player.=Administradores poderão ler as mensagens de qualquer jogador Contributors= -Settings=Ajustes -About=Sobre You have a new message from @1! Subject: @2=Você tem uma mensagem de @1! Assunto: @2 To view it, type /mail=Para visualizar a mensagem, digite /mail You could also use the button in your inventory.=Você também pode usar o botão do seu inventário. @@ -17,18 +15,26 @@ Save draft=Salvar rascunho Send=Enviar CC=CC No contacts= +Edit=Editar +Name=Nome No drafts=Sem rascunhos Player name=Nome do jogador That name is already in your contacts=Esse nome já consta em sua lista de contatos The contact name cannot be empty.=Informe o nome do destinatário +Note=Nota +Back=Voltar Maillist name=Nome da lista de discussão Desc=Descrição Players=Jogador That name is already in your mailing lists.=Esse nome ja está sendo usado em sua lista de discussões The mailing list name cannot be empty.=O nome da lista de discussões deve ser informado -Save=Salvar Mark Read=Marcar como lido Mark Unread=Marcar como não lido +From=De +(No description)=(sem descrição) +No maillist=Sem lista de discussão +Receivers= +You have mail! Type /mail to read=Você recebeu e-mail! Tecle /mail para ler Filter=Filtrar Allow multiple selection=Permitir selecionar vários @1 of @2 selected= @@ -37,8 +43,8 @@ No mail=Sem e-mails no momento Reply=Responder Reply all=Responder Todos Forward=Encaminhar -Ascending=Ascendente -Descending=Descendente +Date=Data +Subject=Assunto Read=Ler Trash= Inbox=Entrada @@ -49,20 +55,11 @@ Mail lists=Lista de correios Options=Opções Close=Fechar (No subject)=(Sem assunto) -(No description)=(sem descrição) -No maillist=Sem lista de discussão -Note=Nota -Edit=Editar -Name=Nome -Back=Voltar -Delete=Apagar New=Novo -Receivers= -You have mail! Type /mail to read=Você recebeu e-mail! Tecle /mail para ler -Subject=Assunto -From=De +Delete=Apagar To=Para -Date=Data +Ascending=Ascendente +Descending=Descendente Add=Adicionar Remove=Remover Notifications=Notificações @@ -77,7 +74,18 @@ Default sorting fields=Ordenamento de campos padrão Other= Move deleted messages to trash= Reset= +Settings=Ajustes +About=Sobre +Save=Salvar +From/To=De/Para +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore= Empty= Trash is empty= -From/To=De/Para diff --git a/locale/mail.zh_CN.tr b/locale/mail.zh_CN.tr index 9dda772..d442e27 100644 --- a/locale/mail.zh_CN.tr +++ b/locale/mail.zh_CN.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)= Communication using this system is NOT guaranteed to be private!= Admins are able to view the messages of any player.= Contributors= -Settings= -About=关于 You have a new message from @1! Subject: @2= To view it, type /mail= You could also use the button in your inventory.= @@ -17,19 +15,27 @@ Save draft=保存草稿 Send=发送 CC=抄送 No contacts= +Edit=编辑 +Name=名字 #if new means new mail, it would be New=新邮件 No drafts=没有草稿 Player name=玩家名字 That name is already in your contacts= The contact name cannot be empty.= +Note=备注 +Back=返回 Maillist name=建组名 Desc=描述 Players=玩家 That name is already in your mailing lists.= The mailing list name cannot be empty.= -Save=保存 Mark Read=标记为已读 Mark Unread=标记为未读 +From=发件人 +(No description)=(无描述) +No maillist=无建组 +Receivers= +You have mail! Type /mail to read= Filter=筛选 Allow multiple selection=允许多选 @1 of @2 selected= @@ -38,8 +44,8 @@ No mail=无邮件 Reply=回复 Reply all=回复所有 Forward=转发 -Ascending=升序 -Descending=降序 +Date=时间 +Subject=主题 Read=浏览 Trash= Inbox=收件箱 @@ -50,20 +56,11 @@ Mail lists=建组 Options= Close=关闭 (No subject)=(无主题) -(No description)=(无描述) -No maillist=无建组 -Note=备注 -Edit=编辑 -Name=名字 -Back=返回 -Delete=删除 New=新 -Receivers= -You have mail! Type /mail to read= -Subject=主题 -From=发件人 +Delete=删除 To=收件人 -Date=时间 +Ascending=升序 +Descending=降序 Add=添加 Remove=移除 Notifications= @@ -78,7 +75,18 @@ Default sorting fields= Other= Move deleted messages to trash= Reset= +Settings= +About=关于 +Save=保存 +From/To= +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore= Empty= Trash is empty= -From/To= diff --git a/locale/mail.zh_TW.tr b/locale/mail.zh_TW.tr index c50f85b..b8018f7 100644 --- a/locale/mail.zh_TW.tr +++ b/locale/mail.zh_TW.tr @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)= Communication using this system is NOT guaranteed to be private!= Admins are able to view the messages of any player.= Contributors= -Settings= -About=關於 You have a new message from @1! Subject: @2= To view it, type /mail= You could also use the button in your inventory.= @@ -17,18 +15,26 @@ Save draft=儲存草稿 Send=發送 CC=副本 No contacts= +Edit=編輯 +Name=名稱 No drafts=沒有草稿 Player name=玩家名稱 That name is already in your contacts= The contact name cannot be empty.= +Note=備註 +Back=返回 Maillist name=郵件列表名稱 Desc=描述 Players=玩家 That name is already in your mailing lists.= The mailing list name cannot be empty.= -Save=儲存 Mark Read=標記已讀 Mark Unread=標記未讀 +From=寄件者 +(No description)=(沒有描述) +No maillist=沒有郵件列表 +Receivers= +You have mail! Type /mail to read= Filter= Allow multiple selection= @1 of @2 selected= @@ -37,8 +43,8 @@ No mail=沒有郵件 Reply=回覆 Reply all=回覆所有人 Forward=轉寄 -Ascending= -Descending= +Date=日期 +Subject=主旨 Read=閱讀 Trash= Inbox=收件箱 @@ -49,20 +55,11 @@ Mail lists=郵件列表 Options= Close=關閉 (No subject)=(沒有主旨) -(No description)=(沒有描述) -No maillist=沒有郵件列表 -Note=備註 -Edit=編輯 -Name=名稱 -Back=返回 -Delete=刪除 New=新建 -Receivers= -You have mail! Type /mail to read= -Subject=主旨 -From=寄件者 +Delete=刪除 To=收件人 -Date=日期 +Ascending= +Descending= Add=加入 Remove=移除 Notifications= @@ -77,7 +74,18 @@ Default sorting fields= Other= Move deleted messages to trash= Reset= +Settings= +About=關於 +Save=儲存 +From/To= +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore= Empty= Trash is empty= -From/To= diff --git a/locale/template.txt b/locale/template.txt index 553cb6d..080241e 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -6,8 +6,6 @@ Expat (code), WTFPL (textures)= Communication using this system is NOT guaranteed to be private!= Admins are able to view the messages of any player.= Contributors= -Settings= -About= You have a new message from @1! Subject: @2= To view it, type /mail= You could also use the button in your inventory.= @@ -17,18 +15,26 @@ Save draft= Send= CC= No contacts= +Edit= +Name= No drafts= Player name= That name is already in your contacts= The contact name cannot be empty.= +Note= +Back= Maillist name= Desc= Players= That name is already in your mailing lists.= The mailing list name cannot be empty.= -Save= Mark Read= Mark Unread= +From= +(No description)= +No maillist= +Receivers= +You have mail! Type /mail to read= Filter= Allow multiple selection= @1 of @2 selected= @@ -37,8 +43,8 @@ No mail= Reply= Reply all= Forward= -Ascending= -Descending= +Date= +Subject= Read= Trash= Inbox= @@ -49,20 +55,11 @@ Mail lists= Options= Close= (No subject)= -(No description)= -No maillist= -Note= -Edit= -Name= -Back= -Delete= New= -Receivers= -You have mail! Type /mail to read= -Subject= -From= +Delete= To= -Date= +Ascending= +Descending= Add= Remove= Notifications= @@ -77,7 +74,18 @@ Default sorting fields= Other= Move deleted messages to trash= Reset= +Settings= +About= +Save= +From/To= +years= +months= +weeks= +days= +hours= +minuts= +seconds= +@1 ago= Restore= Empty= Trash is empty= -From/To= diff --git a/ui/message.lua b/ui/message.lua index d944573..e71d7ab 100644 --- a/ui/message.lua +++ b/ui/message.lua @@ -17,6 +17,7 @@ function mail.show_message(name, id) label[0.2,0.5;]] .. S("To") .. [[: %s] label[0.2,0.9;]] .. S("CC") .. [[: %s] label[0.2,1.3;]] .. S("Date") .. [[: %s] + tooltip[0.2,1.3;4.8,0.4;]] .. mail.time_ago(message.time) .. [[] button[5.1,1;2,1;receivers;]] .. S("Receivers") .. [[] label[0,2.1;]] .. S("Subject") .. [[: %s] diff --git a/util/time_ago.lua b/util/time_ago.lua new file mode 100644 index 0000000..39d912a --- /dev/null +++ b/util/time_ago.lua @@ -0,0 +1,29 @@ +-- translation +local S = minetest.get_translator("mail") + +function mail.time_ago(t) + local elapsed = os.time() - t + local str = "" + + local time_units = { + { S("years"), 31536000 }, + { S("months"), 2592000 }, + { S("weeks"), 604800 }, + { S("days"), 86400 }, + { S("hours"), 3600 }, + { S("minuts"), 60 }, + { S("seconds"), 1 }, + } + + for _, u in ipairs(time_units) do + local n = math.modf(elapsed/u[2]) + if n > 0 then + str = str .. " " .. n .. " " .. u[1] + elapsed = elapsed - n * u[2] + end + end + + str = string.sub(str, 2, -1) + + return S("@1 ago", str) +end