[geary/mjog/589-attachment-keyword-check] ComposerWidget: Send both en and localised attachment keywords



commit 17a23bc57e6a0f6e3c80a609ea5c9f9c1e56b5ab
Author: Michael Gratton <mike vee net>
Date:   Tue Oct 8 22:19:50 2019 +1100

    ComposerWidget: Send both en and localised attachment keywords
    
    Ensures that the English keyword is always checked since en+something
    is somewhat common.
    
    See #589

 src/client/composer/composer-widget.vala | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 31a0dff8..879bacc7 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -161,11 +161,17 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
     private const string URI_LIST_MIME_TYPE = "text/uri-list";
     private const string FILE_URI_PREFIX = "file://";
 
+    // Keep these in sync with the next const below.
+    private const string ATTACHMENT_KEYWORDS =
+        
"attach|attaching|attaches|attachment|attachments|attached|enclose|enclosed|enclosing|encloses|enclosure|enclosures";
     // Translators: This is list of keywords, separated by pipe ("|")
     // characters, that suggest an attachment; since this is full-word
-    // checking, include all variants of each word.  No spaces are
-    // allowed.
-    private const string ATTACHMENT_KEYWORDS_LOCALIZED = 
_("attach|attaching|attaches|attachment|attachments|attached|enclose|enclosed|enclosing|encloses|enclosure|enclosures");
+    // checking, include all variants of each word. No spaces are
+    // allowed. The words will be converted to lower case based on
+    // locale and English versions included automatically.
+    private const string ATTACHMENT_KEYWORDS_LOCALISED =
+        
_("attach|attaching|attaches|attachment|attachments|attached|enclose|enclosed|enclosing|encloses|enclosure|enclosures");
+
 
     public Geary.Account account { get; private set; }
     private Gee.Map<string, Geary.AccountInformation> accounts;
@@ -1334,7 +1340,12 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
             confirmation = _("Send message with an empty body?");
         } else if (!has_attachment &&
                    yield this.editor.contains_attachment_keywords(
-                       ATTACHMENT_KEYWORDS_LOCALIZED, this.subject)) {
+                       string.join(
+                           "|",
+                           ATTACHMENT_KEYWORDS,
+                           ATTACHMENT_KEYWORDS_LOCALISED
+                       ),
+                       this.subject)) {
             confirmation = _("Send message without an attachment?");
         }
         if (confirmation != null) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]