[gnome-software] Allow translation of the 'and' and 'or' terms in the project license



commit 86da0124b4b35bc263b8aca3d0529f63ae5c3908
Author: Richard Hughes <richard hughsie com>
Date:   Tue Aug 26 15:50:56 2014 +0100

    Allow translation of the 'and' and 'or' terms in the project license

 src/plugins/gs-plugin-appstream.c |   42 +++++++++++++++++++++++++++++-------
 1 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 0a2c351..f2a1fb4 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -303,22 +303,48 @@ gs_plugin_appstream_set_license (GsApp *app, const gchar *license_string)
        tokens = as_utils_spdx_license_tokenize (license_string);
        for (i = 0; tokens[i] != NULL; i++) {
 
-               /* literal text */
+               /* translated join */
+               if (g_strcmp0 (tokens[i], "&") == 0) {
+                       /* TRANSLATORS: This is how we join the licences and can
+                        * be considered a "Conjunctive AND Operator" according
+                        * to the SPDX specification. For example:
+                        * "LGPL-2.1 and MIT and BSD-2-Clause" */
+                       g_string_append (urld, _(" and "));
+                       continue;
+               }
+               if (g_strcmp0 (tokens[i], "|") == 0) {
+                       /* TRANSLATORS: This is how we join the licences and can
+                        * be considered a "Disjunctive OR Operator" according
+                        * to the SPDX specification. For example:
+                        * "LGPL-2.1 or MIT" */
+                       g_string_append (urld, _(" or "));
+                       continue;
+               }
+
+               /* legacy literal text */
                if (g_str_has_prefix (tokens[i], "#")) {
                        g_string_append (urld, tokens[i] + 1);
                        continue;
                }
 
-               /* unknown value */
-               if (!as_utils_is_spdx_license_id (tokens[i])) {
-                       g_string_append (urld, tokens[i]);
+               /* SPDX value */
+               if (g_str_has_prefix (tokens[i], "@")) {
+                       g_string_append_printf (urld,
+                                               "<a href=\"http://spdx.org/licenses/%s\";>%s</a>",
+                                               tokens[i] + 1, tokens[i] + 1);
                        continue;
                }
 
-               /* SPDX value */
-               g_string_append_printf (urld,
-                                       "<a href=\"http://spdx.org/licenses/%s\";>%s</a>",
-                                       tokens[i], tokens[i]);
+               /* new SPDX value the extractor didn't know about */
+               if (as_utils_is_spdx_license_id (tokens[i])) {
+                       g_string_append_printf (urld,
+                                               "<a href=\"http://spdx.org/licenses/%s\";>%s</a>",
+                                               tokens[i], tokens[i]);
+                       continue;
+               }
+
+               /* unknown value */
+               g_string_append (urld, tokens[i]);
        }
        gs_app_set_licence (app, urld->str);
        g_strfreev (tokens);


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