Skip to content

Commit

Permalink
Update wording for sharing emails (#4494)
Browse files Browse the repository at this point in the history
  • Loading branch information
nono authored Nov 25, 2024
2 parents 1fd2613 + 16fa224 commit 7daaf58
Show file tree
Hide file tree
Showing 7 changed files with 460 additions and 386 deletions.
39 changes: 27 additions & 12 deletions assets/locales/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ msgstr "Shared by"

msgid "Authorize Sharing Description start"
msgstr ""
"%s and you can collaborate by editing the %s. "
"%s and you can collaborate by editing %s. "
"Each change will be sent automatically between your Cozys."

msgid "Authorize Sharing Description end"
Expand Down Expand Up @@ -1030,22 +1030,22 @@ msgid "Mail New Registration Revoke text"
msgstr "Revoke this device"

msgid "Mail Sharing Request Subject"
msgstr "New sharing from %s"
msgstr "%s has shared %s with you"

msgid "Mail Sharing Request Intro"
msgstr "Hello,"

msgid "Mail Sharing Request Description"
msgstr "%s (%s) invites you to %s the %s **%s** on their personal space, Cozy."
msgstr "%s (%s) invites you to %s %s **%s** from their personal space, Cozy."

msgid "Mail Sharing Request Action Read"
msgstr "access"
msgstr "view"

msgid "Mail Sharing Request Action Write"
msgstr "update"
msgstr "edit"

msgid "Mail Sharing Request Button text"
msgstr "Access to this %s"
msgstr "View %s"

msgid "Mail Sharing Member To Confirm Subject"
msgstr "Confirmation required to finalize the sharing of your passwords"
Expand Down Expand Up @@ -1080,25 +1080,40 @@ msgid "Mail Support Confirmation Signature"
msgstr "Claude - Customer Service at Cozy Cloud"

msgid "Notification Sharing Subject"
msgstr "A new sharing is available in your Cozy"
msgstr "%s has shared %s with you"

msgid "Notification Sharing Description"
msgstr "%s invites you to %s the %s %s"
msgstr "%s invites you to %s the %s **%s**"

msgid "Notification Sharing Type Organization"
msgstr "folder of passwords"

msgid "Notification Sharing Title Document"
msgstr "a document"

msgid "Notification Sharing Title Directory"
msgstr "a directory"

msgid "Notification Sharing Title File"
msgstr "a file"

msgid "Notification Sharing Title Note"
msgstr "a note"

msgid "Notification Sharing Type Document"
msgstr "document"
msgstr "the document"

msgid "Notification Sharing Type Directory"
msgstr "directory"
msgstr "the directory"

msgid "Notification Sharing Type File"
msgstr "file"
msgstr "the file"

msgid "Notification Sharing Type Note"
msgstr "the note"

msgid "Notification Sharing Button text"
msgstr "See the sharing"
msgstr "See %s"

msgid "Sharing Connect to Cozy"
msgstr "Connect to your Cozy"
Expand Down
37 changes: 26 additions & 11 deletions assets/locales/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ msgstr "Partagé par"

msgid "Authorize Sharing Description start"
msgstr ""
"%s et vous pouvez collaborer en modifiant le %s. Chaque modification sera "
"%s et vous pouvez collaborer en modifiant %s. Chaque modification sera "
"transmise automatiquement entre vos Cozy."

msgid "Authorize Sharing Description end"
Expand Down Expand Up @@ -1131,22 +1131,22 @@ msgid "Mail New Registration Revoke text"
msgstr "Révoquer cet appareil"

msgid "Mail Sharing Request Subject"
msgstr "Accepter le partage de %s ?"
msgstr "%s a partagé %s avec vous"

msgid "Mail Sharing Request Intro"
msgstr "Bonjour,"

msgid "Mail Sharing Request Description"
msgstr "%s (%s) vous invite à %s le %s **%s** sur son espace personnel, Cozy."
msgstr "%s (%s) vous invite à %s %s **%s** depuis son espace personnel, Cozy."

msgid "Mail Sharing Request Action Read"
msgstr "consulter"
msgstr "voir"

msgid "Mail Sharing Request Action Write"
msgstr "modifier"

msgid "Mail Sharing Request Button text"
msgstr "Accéder au %s"
msgstr "Voir %s"

msgid "Mail Sharing Member To Confirm Subject"
msgstr "Vérification demandée pour finaliser le partage de vos mot de passe"
Expand Down Expand Up @@ -1183,25 +1183,40 @@ msgid "Mail Support Confirmation Signature"
msgstr "Claude - Service Client chez Cozy Cloud"

msgid "Notification Sharing Subject"
msgstr "Vous avez un nouveau partage disponible dans votre Cozy"
msgstr "%s a partagé %s avec vous"

msgid "Notification Sharing Description"
msgstr "%s vous invite à %s le %s %s"
msgstr "%s vous invite à %s le %s **%s**"

msgid "Notification Sharing Type Organization"
msgstr "dossier partagé de mots de passe"

msgid "Notification Sharing Title Document"
msgstr "un document"

msgid "Notification Sharing Title Directory"
msgstr "un répertoire"

msgid "Notification Sharing Title File"
msgstr "un fichier"

msgid "Notification Sharing Title Note"
msgstr "une note"

msgid "Notification Sharing Type Document"
msgstr "document"
msgstr "le document"

msgid "Notification Sharing Type Directory"
msgstr "répertoire"
msgstr "le répertoire"

msgid "Notification Sharing Type File"
msgstr "fichier"
msgstr "le fichier"

msgid "Notification Sharing Type Note"
msgstr "la note"

msgid "Notification Sharing Button text"
msgstr "Voir le partage"
msgstr "Voir %s"

msgid "Sharing Connect to Cozy"
msgstr "Renseignez l'adresse de votre Cozy"
Expand Down
6 changes: 3 additions & 3 deletions assets/mails/notifications_sharing.mjml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{define "content"}}
<mj-text mj-class="title content-medium">
<img src="https://files.cozycloud.cc/email-assets/stack/icon-share.png" width="16" height="16" style="vertical-align:sub;"/>&nbsp;
{{t "Notification Sharing Subject"}}
{{t "Notification Sharing Subject" .SharerPublicName .TargetType}}
</mj-text>
<mj-text mj-class="content-medium">
{{t "Notification Sharing Description" .SharerPublicName .Action .TargetType .TargetName}}
{{tHTML "Notification Sharing Description" .SharerPublicName .Action .TargetType .TargetName}}
</mj-text>
<mj-button href="{{.SharingLink}}" align="left" mj-class="primary-button content-xlarge">
{{t "Notification Sharing Button text"}}
{{t "Notification Sharing Button text" .TargetType}}
</mj-button>
{{end}}
2 changes: 1 addition & 1 deletion assets/mails/sharing_request.mjml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{define "content"}}
<mj-text mj-class="title content-medium">
<img src="https://files.cozycloud.cc/email-assets/stack/icon-share.png" width="16" height="16" style="vertical-align:sub;"/>&nbsp;
{{t "Mail Sharing Request Subject" .SharerPublicName}}
{{t "Mail Sharing Request Subject" .SharerPublicName .DocType}}
</mj-text>
<mj-text mj-class="content-medium">
{{t "Mail Sharing Request Intro"}}
Expand Down
43 changes: 43 additions & 0 deletions model/sharing/invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/url"
"runtime/debug"
"strings"
"time"

"github.com/cozy/cozy-stack/model/instance"
Expand Down Expand Up @@ -189,12 +190,14 @@ func (m *Member) SendMail(inst *instance.Instance, s *Sharing, sharer, descripti
} else {
action = inst.Translate("Mail Sharing Request Action Write")
}
titleType := getDocumentTitleType(inst, s)
docType := getDocumentType(inst, s)
mailValues := map[string]interface{}{
"SharerPublicName": sharer,
"SharerEmail": sharerMail,
"Action": action,
"Description": description,
"TitleType": titleType,
"DocType": docType,
"SharingLink": link,
}
Expand All @@ -216,6 +219,24 @@ func (m *Member) SendMail(inst *instance.Instance, s *Sharing, sharer, descripti
return err
}

func getDocumentTitleType(inst *instance.Instance, s *Sharing) string {
rule := s.FirstFilesRule()
if rule == nil {
if len(s.Rules) > 0 && s.Rules[0].DocType == consts.BitwardenOrganizations {
return inst.Translate("Notification Sharing Title Organization")
}
return inst.Translate("Notification Sharing Title Document")
}
_, err := inst.VFS().FileByID(rule.Values[0])
if err != nil {
return inst.Translate("Notification Sharing Title Directory")
}
if strings.HasSuffix(s.Description, ".cozy-note") {
return inst.Translate("Notification Sharing Title Note")
}
return inst.Translate("Notification Sharing Title File")
}

func getDocumentType(inst *instance.Instance, s *Sharing) string {
rule := s.FirstFilesRule()
if rule == nil {
Expand All @@ -228,6 +249,9 @@ func getDocumentType(inst *instance.Instance, s *Sharing) string {
if err != nil {
return inst.Translate("Notification Sharing Type Directory")
}
if strings.HasSuffix(s.Description, ".cozy-note") {
return inst.Translate("Notification Sharing Type Note")
}
return inst.Translate("Notification Sharing Type File")
}

Expand Down Expand Up @@ -342,10 +366,12 @@ func (s *Sharing) SendShortcutMail(inst *instance.Instance, fileDoc *vfs.FileDoc
} else {
action = inst.Translate("Mail Sharing Request Action Write")
}
titleType := getTargetTitleType(inst, fileDoc.Metadata)
targetType := getTargetType(inst, fileDoc.Metadata)
mailValues := map[string]interface{}{
"SharerPublicName": sharerName,
"Action": action,
"TitleType": titleType,
"TargetType": targetType,
"TargetName": s.Description,
"SharingLink": previewURL,
Expand All @@ -366,11 +392,28 @@ func (s *Sharing) SendShortcutMail(inst *instance.Instance, fileDoc *vfs.FileDoc
return err
}

func getTargetTitleType(inst *instance.Instance, metadata map[string]interface{}) string {
target, _ := metadata["target"].(map[string]interface{})
if target["_type"] != consts.Files {
return inst.Translate("Notification Sharing Title Document")
}
if target["mime"] == consts.NoteMimeType {
return inst.Translate("Notification Sharing Title Note")
}
if target["mime"] == nil || target["mime"] == "" {
return inst.Translate("Notification Sharing Title Directory")
}
return inst.Translate("Notification Sharing Title File")
}

func getTargetType(inst *instance.Instance, metadata map[string]interface{}) string {
target, _ := metadata["target"].(map[string]interface{})
if target["_type"] != consts.Files {
return inst.Translate("Notification Sharing Type Document")
}
if target["mime"] == consts.NoteMimeType {
return inst.Translate("Notification Sharing Type Note")
}
if target["mime"] == nil || target["mime"] == "" {
return inst.Translate("Notification Sharing Type Directory")
}
Expand Down
Loading

0 comments on commit 7daaf58

Please sign in to comment.