diff --git a/locale/mail.de.tr b/locale/mail.de.tr index c95e11e..f368cd4 100644 --- a/locale/mail.de.tr +++ b/locale/mail.de.tr @@ -1,28 +1,33 @@ # textdomain: mail +Provided my mt-mods= +Version= +Licenses= +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= +Note=Notiz BCC=BCC Cancel=Abbrechen Save draft=Entwurf Speichern Send=Senden -Edit=Bearbeiten +CC=CC +Subject=Betreff +To=An +Back=Zurück New=Neu Delete=Löschen No drafts=Keine Entwürfe Player name=Spielername -your contacts.=ihre Kontakte. -The contact=Der Kontakt +That name is already in your contacts= +The contact name cannot be empty.= Maillist name=Verteilerlistenname Desc=Beschreibung Players=Spieler -your maillists.=ihre Verteilerlisten. -The maillist=Die Verteilerliste -Save=Speichern -That name=Der Name -is already in=ist bereits in -name cannot=Name kann nicht -be empty.=leer sein. +That name is already in your mailing lists.= +The mailing list name cannot be empty.= Mark Read=Als gelesen makieren Mark Unread=Als ungelesen makieren -From=Von Read=Lesen Filter= Allow multiple selection= @@ -31,7 +36,12 @@ selected= No mail=Keine Nachrichten (No description)=(Keine Beschreibung) No maillist=Keine Verteilerliste -Subject=Betreff +Edit=Bearbeiten +Name=Name +From=Von +Reply=Antworten +Reply all=Allen antworten +Forward=Weiter Inbox=Posteingang Sent messages=Nachrichten senden Drafts=Entwürfe @@ -40,16 +50,8 @@ Mail lists=Verteilerlisten Options= Close=Schließen (No subject)=(Kein Betreff) -Reply=Antworten -Reply all=Allen antworten -Forward=Weiter Add=Hinzufügen Remove=Entfernen -CC=CC -Note=Notiz -Back=Zurück -Name=Name -To=An Notifications= Chat notifications= On join notifications= @@ -58,10 +60,23 @@ Message list= Show unread in different color= Show CC/BCC in different color= Default sorting fields= -From/To= +From/To=Von/An Reset= Settings= About=Über +Save=Speichern Ascending= Descending= Date=Datum + + +##### not used anymore ##### + +That name=Der Name +is already in=ist bereits in +your maillists.=ihre Verteilerlisten. +The maillist=Die Verteilerliste +name cannot=Name kann nicht +be empty.=leer sein. +your contacts.=ihre Kontakte. +The contact=Der Kontakt diff --git a/locale/mail.fr.tr b/locale/mail.fr.tr index bc94c5e..a9b6437 100644 --- a/locale/mail.fr.tr +++ b/locale/mail.fr.tr @@ -1,28 +1,33 @@ # textdomain: mail +Provided my mt-mods=Fourni par mt-mods +Version=Version +Licenses=Licences +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 +Note=Note BCC=Cci Cancel=Annuler Save draft=Enregistrer le brouillon Send=Envoyer -Edit=Modifier +CC=Cc +Subject=Objet +To=À +Back=Retour New=Nouveau Delete=Supprimer No drafts=Pas de brouillons Player name=Nom du joueur -your contacts.=vos contacts. -The contact=Ce contact +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. Maillist name=Nom de la liste de diffusion Desc=Desc Players=Joueurs -your maillists.=vos listes de diffusion. -The maillist=Cette liste de diffusion -Save=Sauvegarder -That name=Ce nom -is already in=existe déjà -name cannot=nom ne peut pas -be empty.=être vide. +That name is already in your mailing lists.=Ce nom est déjà dans vos listes de diffusion. +The mailing list name cannot be empty.=Le nom de la liste de diffusion ne peut pas être vide. Mark Read=Marquer comme lu Mark Unread=Marquer non lu -From=De Read=Lire Filter=Filtre Allow multiple selection=Autoriser la sélection multiple @@ -31,7 +36,12 @@ selected=sélectionnés No mail=Aucun mail (No description)=Sans description No maillist=Aucune liste de diffusion -Subject=Objet +Edit=Modifier +Name=Nom +From=De +Reply=Répondre +Reply all=Répondre à tous +Forward=Transférer Inbox=Boîte de réception Sent messages=Messages envoyés Drafts=Brouillons @@ -40,16 +50,8 @@ Mail lists=Listes de diffusion Options=Options Close=Fermer (No subject)=(Sans objet) -Reply=Répondre -Reply all=Répondre à tous -Forward=Transférer Add=Ajouter Remove=Enlever -CC=Cc -Note=Note -Back=Retour -Name=Nom -To=À Notifications=Notifications Chat notifications=Notifications dans le tchat On join notifications=Notifications à la connexion @@ -62,6 +64,7 @@ From/To=De/À Reset=Réinitialiser Settings=Paramètres About=À propos +Save=Sauvegarder Ascending=Croissant Descending=Décroissant Date=Date diff --git a/locale/mail.zh_TW.tr b/locale/mail.zh_TW.tr index 5e5aa6a..8209df1 100644 --- a/locale/mail.zh_TW.tr +++ b/locale/mail.zh_TW.tr @@ -1,28 +1,33 @@ # textdomain: mail +Provided my mt-mods= +Version= +Licenses= +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= +Note=備註 BCC=密件副本 Cancel=取消 Save draft=儲存草稿 Send=發送 -Edit=編輯 +CC=副本 +Subject=主旨 +To=收件人 +Back=返回 New=新建 Delete=刪除 No drafts=沒有草稿 Player name=玩家名稱 -your contacts.= -The contact= +That name is already in your contacts= +The contact name cannot be empty.= Maillist name=郵件列表名稱 Desc=描述 Players=玩家 -your maillists.= -The maillist= -Save=儲存 -That name= -is already in= -name cannot= -be empty.= +That name is already in your mailing lists.= +The mailing list name cannot be empty.= Mark Read=標記已讀 Mark Unread=標記未讀 -From=寄件者 Read=閱讀 Filter= Allow multiple selection= @@ -31,7 +36,12 @@ selected= No mail=沒有郵件 (No description)=(沒有描述) No maillist=沒有郵件列表 -Subject=主旨 +Edit=編輯 +Name=名稱 +From=寄件者 +Reply=回覆 +Reply all=回覆所有人 +Forward=轉寄 Inbox=收件箱 Sent messages=寄件備份 Drafts=草稿 @@ -40,16 +50,8 @@ Mail lists=郵件列表 Options= Close=關閉 (No subject)=(沒有主旨) -Reply=回覆 -Reply all=回覆所有人 -Forward=轉寄 Add=加入 Remove=移除 -CC=副本 -Note=備註 -Back=返回 -Name=名稱 -To=收件人 Notifications= Chat notifications= On join notifications= @@ -62,6 +64,7 @@ From/To= Reset= Settings= About=關於 +Save=儲存 Ascending= Descending= Date=日期 diff --git a/locale/template.txt b/locale/template.txt index 63e9174..400c12e 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -1,28 +1,33 @@ # textdomain: mail +Provided my mt-mods= +Version= +Licenses= +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= +Note= BCC= Cancel= Save draft= Send= -Edit= +CC= +Subject= +To= +Back= New= Delete= No drafts= Player name= -your contacts.= -The contact= +That name is already in your contacts= +The contact name cannot be empty.= Maillist name= Desc= Players= -your maillists.= -The maillist= -Save= -That name= -is already in= -name cannot= -be empty.= +That name is already in your mailing lists.= +The mailing list name cannot be empty.= Mark Read= Mark Unread= -From= Read= Filter= Allow multiple selection= @@ -31,7 +36,12 @@ selected= No mail= (No description)= No maillist= -Subject= +Edit= +Name= +From= +Reply= +Reply all= +Forward= Inbox= Sent messages= Drafts= @@ -40,16 +50,8 @@ Mail lists= Options= Close= (No subject)= -Reply= -Reply all= -Forward= Add= Remove= -CC= -Note= -Back= -Name= -To= Notifications= Chat notifications= On join notifications= @@ -62,6 +64,7 @@ From/To= Reset= Settings= About= +Save= Ascending= Descending= Date= diff --git a/storage.lua b/storage.lua index 8bdc213..217d502 100644 --- a/storage.lua +++ b/storage.lua @@ -178,6 +178,17 @@ function mail.get_contacts(playername) return entry.contacts end +-- get a contact +function mail.get_contact(playername, contactname) + local entry = mail.get_storage_entry(playername) + for _, existing_contact in ipairs(entry.contacts) do + if existing_contact.name == contactname then + return existing_contact + end + end + return false +end + -- returns the maillists of a player function mail.get_maillists(playername) local entry = mail.get_storage_entry(playername) diff --git a/ui/about.lua b/ui/about.lua index 28ffd3c..4259836 100644 --- a/ui/about.lua +++ b/ui/about.lua @@ -9,19 +9,19 @@ function mail.show_about(name) tabheader[0.3,1;optionstab;]] .. S("Settings") .. "," .. S("About") .. [[;2;false;false] button[9.35,0;0.75,0.5;back;X] label[0,0.8;Mail] - label[0,1.2;Provided my mt-mods] - label[0,1.6;Version: 1.2.0-dev] - label[0,2.2;Licenses:] - label[0.2,2.6;Expat (code), WTFPL (textures)] + label[0,1.2;]] .. S("Provided my mt-mods") .. [[] + label[0,1.6;]] .. S("Version") .. [[ : 1.2.0-dev] + label[0,2.2;]] .. S("Licenses") .. [[ :] + label[0.2,2.6;]] .. S("Expat (code), WTFPL (textures)") .. [[] label[0,3.2;https://github.com/mt-mods/mail] label[0,3.6;https://content.minetest.net/packages/mt-mods/mail] - textarea[0.5,4.8;4,5.5;;Note;]] .. - [[NOTE: Communication using this system is NOT guaranteed to be private!]] .. - [[ Admins are able to view the messages of any player.] + textarea[0.5,4.8;4,5.5;;]] .. S("Note") .. [[;]] .. + S("Communication using this system is NOT guaranteed to be private!") .. " " .. + S("Admins are able to view the messages of any player.") .. [[] tablecolumns[color;text;text] table[5,0.75;4.9,5.5;contributors;]] .. - [[#999,Contributors,,]] .. + [[#999,]] .. S("Contributors") .. [[,,]] .. [[#FFD700,Cheapie,Initial idea/project,]] .. [[#FFF,Rubenwardy,Lua/UI improvements,]] .. [[#FFF,BuckarooBanzay,Clean-ups\, Refactoring,]] .. diff --git a/ui/contacts.lua b/ui/contacts.lua index 25f5dcc..bf5ae53 100644 --- a/ui/contacts.lua +++ b/ui/contacts.lua @@ -29,7 +29,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local evt = minetest.explode_table_event(fields.contacts) for k, _, i in mail.pairsByKeys(contacts) do if i == evt.row - 1 then - mail.selected_idxs.contacts[name] = k + mail.selected_idxs.contacts[name] = tonumber(k) break end end @@ -60,14 +60,14 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local last = nil for k in mail.pairsByKeys(contacts) do if found then - mail.selected_idxs.contacts[name] = k + mail.selected_idxs.contacts[name] = tonumber(k) break elseif k == mail.selected_idxs.contacts[name] then mail.delete_contact(name, contacts[mail.selected_idxs.contacts[name]].name) mail.selected_idxs.contacts[name] = nil found = true else - last = k + last = tonumber(k) end end if found and not mail.selected_idxs.contacts[name] then diff --git a/ui/edit_contact.lua b/ui/edit_contact.lua index cac5fee..1eeea16 100644 --- a/ui/edit_contact.lua +++ b/ui/edit_contact.lua @@ -13,15 +13,13 @@ function mail.show_edit_contact(name, contact_name, note, illegal_name_hint) ]] if illegal_name_hint == "collision" then formspec = formspec .. [[ - label[4,1;]] .. S("That name") .. [[] - label[4,1.5;]] .. S("is already in") .. [[] - label[4,2;]] .. S("your contacts.") .. [[] + textarea[4.25,1;2.5,6;;;]] .. + S("That name is already in your contacts") .. [[] ]] elseif illegal_name_hint == "empty" then formspec = formspec .. [[ - label[4,1;]] .. S("The contact") .. [[] - label[4,1.5;]] .. S("name cannot") .. [[] - label[4,2;]] .. S("be empty.") .. [[] + textarea[4.25,1;2.5,6;;;]] .. + S("The contact name cannot be empty.") .. [[] ]] end formspec = formspec .. mail.theme @@ -40,19 +38,21 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) local contacts = mail.get_contacts(name) if fields.save then - if mail.selected_idxs.contacts[name] and mail.selected_idxs.contacts[name] ~= "#NEW#" then - local contact = contacts[mail.selected_idxs.contacts[name]] - if mail.selected_idxs.contacts[name] ~= string.lower(fields.name) then + if mail.selected_idxs.contacts[name] then + local contact = contacts[mail.selected_idxs.contacts[name]] or {name = ""} + if contact.name ~= fields.name or fields.name == "" then -- name changed! if #fields.name == 0 then mail.show_edit_contact(name, contact.name, fields.note, "empty") return true - elseif contacts[string.lower(fields.name)] ~= nil then + elseif mail.get_contact(name, fields.name) then mail.show_edit_contact(name, contact.name, fields.note, "collision") return true else + contact.name = fields.name + contact.note = fields.note mail.update_contact(name, contact) contacts[mail.selected_idxs.contacts[name]] = nil end diff --git a/ui/edit_maillists.lua b/ui/edit_maillists.lua index 847a860..ced3d2b 100644 --- a/ui/edit_maillists.lua +++ b/ui/edit_maillists.lua @@ -16,15 +16,13 @@ function mail.show_edit_maillist(playername, maillist_name, desc, players, illeg ]] if illegal_name_hint == "collision" then formspec = formspec .. [[ - label[4,1;]] .. S("That name") .. [[] - label[4,1.5;]] .. S("is already in") .. [[] - label[4,2;]] .. S("your maillists.") .. [[] + textarea[4.25,1;2.5,6;;;]] .. + S("That name is already in your mailing lists.") .. [[] ]] elseif illegal_name_hint == "empty" then formspec = formspec .. [[ - label[4,1;]] .. S("The maillist") .. [[] - label[4,1.5;]] .. S("name cannot") .. [[] - label[4,2;]] .. S("be empty.") .. [[] + textarea[4.25,1;2.5,6;;;]] .. + S("The mailing list name cannot be empty.") .. [[] ]] end formspec = formspec .. mail.theme @@ -41,13 +39,46 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end local name = player:get_player_name() + local maillists = mail.get_maillists(name) + if fields.save then - mail.update_maillist(name, { - owner = name, - name = fields.name, - desc = fields.desc, - players = mail.parse_player_list(fields.players) - }, old_lists_names[name]) + if mail.selected_idxs.maillists[name] then + local maillist = maillists[mail.selected_idxs.maillists[name]] or {name = ""} + if maillist.name ~= fields.name or fields.name == "" then + -- name changed! + if #fields.name == 0 then + mail.show_edit_maillist(name, maillist.name, fields.desc, fields.players, "empty") + return true + + elseif mail.get_maillist_by_name(name, fields.name) then + mail.show_edit_maillist(name, maillist.name, fields.desc, fields.players, "collision") + return true + + else + mail.update_maillist(name, { + owner = name, + name = fields.name, + desc = fields.desc, + players = mail.parse_player_list(fields.players) + }, old_lists_names[name]) + maillists[mail.selected_idxs.maillists[name]] = nil + end + else + mail.update_maillist(name, { + owner = name, + name = fields.name, + desc = fields.desc, + players = mail.parse_player_list(fields.players) + }, old_lists_names[name]) + end + else + mail.update_maillist(name, { + owner = name, + name = fields.name, + desc = fields.desc, + players = mail.parse_player_list(fields.players) + }, old_lists_names[name]) + end mail.show_maillists(name) elseif fields.back then