[gnome-dictionary] Use a new key for the source description



commit 6bb810722f0f312b4746816ae06cc9731314051e
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Tue Apr 11 21:27:46 2017 +0100

    Use a new key for the source description
    
    Use 'Comment', which is the same key desktop files use. This allows
    extracting the localised description string using Gettext instead of
    intltool.

 libgdict/gdict-source.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/libgdict/gdict-source.c b/libgdict/gdict-source.c
index 4e5b47c..d6f8b62 100644
--- a/libgdict/gdict-source.c
+++ b/libgdict/gdict-source.c
@@ -51,7 +51,8 @@
 
 /* Common keys */
 #define SOURCE_KEY_NAME                "Name"
-#define SOURCE_KEY_DESCRIPTION "Description"
+#define SOURCE_KEY_DESCRIPTION "Description" /* Deprecated */
+#define SOURCE_KEY_COMMENT     "Comment"
 #define SOURCE_KEY_TRANSPORT   "Transport"
 #define SOURCE_KEY_DATABASE    "Database"
 #define SOURCE_KEY_STRATEGY    "Strategy"
@@ -487,11 +488,20 @@ gdict_source_parse (GdictSource  *source,
     }
   
   /* if present, fetch the localized description */
-  if (g_key_file_has_key (priv->keyfile, SOURCE_GROUP, SOURCE_KEY_DESCRIPTION, NULL))
+  const char *description_key;
+
+  if (g_key_file_has_key (priv->keyfile, SOURCE_GROUP, SOURCE_KEY_COMMENT, NULL))
+    description_key = SOURCE_KEY_COMMENT;
+  else if (g_key_file_has_key (priv->keyfile, SOURCE_GROUP, SOURCE_KEY_DESCRIPTION, NULL))
+    description_key = SOURCE_KEY_DESCRIPTION;
+  else
+    description_key = NULL;
+
+  if (description_key != NULL)
     {
       priv->description = g_key_file_get_locale_string (priv->keyfile,
                                                         SOURCE_GROUP,
-                                                        SOURCE_KEY_DESCRIPTION,
+                                                        description_key,
                                                         NULL,
                                                         &parse_error);
       if (parse_error)
@@ -500,7 +510,7 @@ gdict_source_parse (GdictSource  *source,
                        GDICT_SOURCE_ERROR_PARSE,
                        _("Unable to get the ā€œ%sā€ key inside the dictionary "
                          "source definition: %s"),
-                       SOURCE_KEY_DESCRIPTION,
+                       description_key,
                        parse_error->message);
                        
           g_error_free (parse_error);


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