guix-commits
[Top][All Lists]
Advanced

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

03/07: Add indications for no translations available in the packages pag


From: Christopher Baines
Subject: 03/07: Add indications for no translations available in the packages page
Date: Fri, 26 Jun 2020 12:55:11 -0400 (EDT)

cbaines pushed a commit to branch master
in repository data-service.

commit f16fdb44f12beed1afbb1bf2cd0270e79154f4e6
Author: Danjela Lura <danielaluraa@gmail.com>
AuthorDate: Tue Jun 23 13:44:18 2020 +0200

    Add indications for no translations available in the packages page
    
    Signed-off-by: Christopher Baines <mail@cbaines.net>
---
 guix-data-service/model/package.scm           | 12 +++++++++++-
 guix-data-service/web/revision/controller.scm |  6 +++++-
 guix-data-service/web/revision/html.scm       | 22 ++++++++++++++++++----
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/guix-data-service/model/package.scm 
b/guix-data-service/model/package.scm
index 643148d..43871ec 100644
--- a/guix-data-service/model/package.scm
+++ b/guix-data-service/model/package.scm
@@ -32,7 +32,9 @@
             select-package-versions-for-revision
             package-versions-for-branch
             package-derivations-for-branch
-            package-outputs-for-branch))
+            package-outputs-for-branch
+
+            any-package-synopsis-or-descriptions-translations?))
 
 (define (select-existing-package-entries package-entries)
   (string-append "SELECT id, packages.name, packages.version, "
@@ -530,3 +532,11 @@ ORDER BY first_datetime DESC, package_version DESC")
               output-name
               system
               target))))
+
+(define (any-package-synopsis-or-descriptions-translations? packages locale)
+  (any
+   (match-lambda
+     ((name version synopsis synopsis-locale description description-locale _ 
_ _ _ _)
+      (or (string=? synopsis-locale locale)
+          (string=? description-locale locale))))
+   packages))
diff --git a/guix-data-service/web/revision/controller.scm 
b/guix-data-service/web/revision/controller.scm
index e233fe7..a038e5c 100644
--- a/guix-data-service/web/revision/controller.scm
+++ b/guix-data-service/web/revision/controller.scm
@@ -568,6 +568,7 @@
              (limit-results (or (assq-ref query-parameters 'limit_results)
                                 99999)) ; TODO There shouldn't be a limit
              (fields (assq-ref query-parameters 'field))
+             (locale (assq-ref query-parameters 'locale))
              (packages
               (if search-query
                   (search-packages-in-revision
@@ -587,7 +588,9 @@
              (show-next-page?
               (and (not search-query)
                    (>= (length packages)
-                       limit-results))))
+                       limit-results)))
+             (any-translations? 
(any-package-synopsis-or-descriptions-translations?
+                                packages locale)))
         (case (most-appropriate-mime-type
                '(application/json text/html)
                mime-types)
@@ -638,6 +641,7 @@
                                            git-repositories
                                            show-next-page?
                                            
description-and-synopsis-locale-options
+                                           any-translations?
                                            #:path-base path-base
                                            #:header-text header-text
                                            #:header-link header-link)
diff --git a/guix-data-service/web/revision/html.scm 
b/guix-data-service/web/revision/html.scm
index bc1aff7..cf34d5f 100644
--- a/guix-data-service/web/revision/html.scm
+++ b/guix-data-service/web/revision/html.scm
@@ -532,6 +532,7 @@
                                  git-repositories
                                  show-next-page?
                                  locale-options
+                                 any-translations-available?
                                  #:key path-base
                                  header-text header-link)
   (define field-options
@@ -571,7 +572,10 @@
             #:options locale-options
             #:allow-selecting-multiple-options #f
             #:help-text
-            "Language.")
+            (if any-translations-available?
+                "Language."
+                '((span (@ (class "text-danger"))
+                       "No translations available in this page."))))
           ,(form-horizontal-control
             "Search query" query-parameters
             #:help-text
@@ -632,7 +636,7 @@
           ,@(let ((fields (assq-ref query-parameters 'field)))
               (map
                (match-lambda
-                 ((name version synopsis _ description _ home-page
+                 ((name version synopsis synopsis-locale description 
description-locale home-page
                         location-file location-line
                         location-column-number licenses)
                   `(tr
@@ -641,10 +645,20 @@
                           `((td ,version))
                           '())
                     ,(if (member "synopsis" fields)
-                         `((td ,(stexi->shtml (texi-fragment->stexi 
synopsis))))
+                         `((td ,(stexi->shtml (texi-fragment->stexi synopsis))
+                               ,(if (string=? synopsis-locale
+                                              (assq-ref query-parameters 
'locale))
+                                    ""
+                                    '((span (@ (class "text-danger"))
+                                            "No translation available for 
synopsis.")))))
                          '())
                     ,(if (member "description" fields)
-                         `((td ,(stexi->shtml (texi-fragment->stexi 
description))))
+                         `((td ,(stexi->shtml (texi-fragment->stexi 
description))
+                               ,(if (string=? description-locale
+                                              (assq-ref query-parameters 
'locale))
+                                    ""
+                                    '((span (@ (class "text-danger"))
+                                            "No translation available for 
description.")))))
                          '())
                     ,(if (member "home-page" fields)
                          `((td ,home-page))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]