liquid_feedback_frontend

changeset 1792:fe28be5403e2

Better handling of combined sentence on suggestion rating
author bsw
date Wed Oct 20 16:21:32 2021 +0200 (2021-10-20)
parents 4edec387855f
children 91d31b3eb56c
files app/main/initiative/_suggestions.lua locale/translations.de.lua locale/translations.el.lua locale/translations.en.lua locale/translations.fr.lua locale/translations.it.lua locale/translations.ka.lua static/js/xhr.js
line diff
     1.1 --- a/app/main/initiative/_suggestions.lua	Wed Oct 20 16:04:30 2021 +0200
     1.2 +++ b/app/main/initiative/_suggestions.lua	Wed Oct 20 16:21:32 2021 +0200
     1.3 @@ -251,37 +251,38 @@
     1.4            if direct_supporter then
     1.5              ui.container{ attr = { class = "suggestion_rating_info" }, content = function()
     1.6                ui.tag{ attr = { id = "s" .. suggestion.id .. "_rating_text" }, content = function()
     1.7 -                local text = ""
     1.8 +                local text_opinion = ""
     1.9                  if opinion then
    1.10 -                  if opinion.degree == 2 then
    1.11 -                    text = _"must"
    1.12 -                  elseif opinion.degree == 1 then
    1.13 -                    text = _"should"
    1.14 -                  elseif opinion.degree == 0 then
    1.15 -                    text = _"neutral"
    1.16 -                  elseif opinion.degree == -1 then
    1.17 -                    text = _"should not"
    1.18 -                  elseif opinion.degree == -2 then
    1.19 -                    text = _"must not"
    1.20 -                  end
    1.21 -                  ui.tag { content = text }
    1.22 -                  slot.put ( " " )
    1.23 +                  local text_template
    1.24                    if 
    1.25                      (opinion.degree > 0 and not opinion.fulfilled)
    1.26                      or (opinion.degree < 0 and opinion.fulfilled)
    1.27                    then
    1.28 -                    ui.tag{ content = _"but" }
    1.29 +                    text_template = _"#{opinion} but #{implemented}"
    1.30                    else
    1.31 -                    ui.tag{ content = _"and" }
    1.32 +                    text_template = _"#{opinion} and #{implemented}"
    1.33                    end
    1.34 -                  slot.put ( " " )
    1.35 -                  local text = ""
    1.36 +                  if opinion.degree == 2 then
    1.37 +                    text_opinion = _"must"
    1.38 +                  elseif opinion.degree == 1 then
    1.39 +                    text_opinion = _"should"
    1.40 +                  elseif opinion.degree == 0 then
    1.41 +                    text_opinion = _"neutral"
    1.42 +                  elseif opinion.degree == -1 then
    1.43 +                    text_opinion = _"should not"
    1.44 +                  elseif opinion.degree == -2 then
    1.45 +                    text_opinion = _"must not"
    1.46 +                  end
    1.47 +                  local text_implemented = ""
    1.48                    if opinion.fulfilled then
    1.49 -                    text = _"is implemented"
    1.50 +                    text_implemented = _"is implemented"
    1.51                    else
    1.52 -                    text = _"is not implemented"
    1.53 +                    text_implemented = _"is not implemented"
    1.54                    end
    1.55 -                  ui.tag { content = text }
    1.56 +                  ui.tag { content = _(text_template, {
    1.57 +                    opinion = text_opinion,
    1.58 +                    implemented = text_implemented
    1.59 +                  }) }
    1.60                  end
    1.61                end }
    1.62                local id = "s" .. suggestion.id .. "_rating_icon"
    1.63 @@ -332,14 +333,14 @@
    1.64          ui.script{ script = [[
    1.65            var rateSuggestionRateText = "]] .. _"rate suggestion" .. [[";
    1.66            var rateSuggestionUpdateRatingText = "]] .. _"update rating" .. [[";
    1.67 +          var rateSuggestionAndText = "]] .. _"#{opinion} and #{implemented}" .. [[";
    1.68 +          var rateSuggestionButText = "]] .. _"#{opinion} but #{implemented}" .. [[";
    1.69            var rateSuggestionDegreeTexts = {
    1.70              "-2": "]] .. _"must not" .. [[",
    1.71              "-1": "]] .. _"should not" .. [[",
    1.72              "1": "]] .. _"should" .. [[",
    1.73              "2": "]] .. _"must" .. [["
    1.74            }
    1.75 -          var rateSuggestionAndText = "]] .. _"and" .. [[";
    1.76 -          var rateSuggestionButText = "]] .. _"but" .. [[";
    1.77            var rateSuggestionFulfilledText = "]] .. _"is implemented" .. [[";
    1.78            var rateSuggestionNotFulfilledText = "]] .. _"is not implemented" .. [[";
    1.79            window.addEventListener("load", function() {
     2.1 --- a/locale/translations.de.lua	Wed Oct 20 16:04:30 2021 +0200
     2.2 +++ b/locale/translations.de.lua	Wed Oct 20 16:21:32 2021 +0200
     2.3 @@ -861,8 +861,9 @@
     2.4  ["all results"] = "Alle Ergebnisse";
     2.5  ["all subject areas"] = "Alle Themenbereiche";
     2.6  ["allow invitation again"] = "Einladen wieder erlauben";
     2.7 -["and"] = "und";
     2.8  ["and #{count} more initiatives"] = "und #{count} weitere Initiativen";
     2.9 +["#{opinion} and #{implemented}"] = "#{opinion} und #{implemented}";
    2.10 +["#{opinion} but #{implemented}"] = "#{opinion} aber #{implemented}";
    2.11  ["area"] = "Themenbereich";
    2.12  ["at least #{count} approvals"] = "mindestens #{count} Zustimmungen";
    2.13  ["at least #{count} approvals or abstentions"] = "mindestens #{count} Zustimmungen oder Enthaltungen";
    2.14 @@ -873,7 +874,6 @@
    2.15  ["browse the platform as a guest"] = "Die Plattform als Gast erkunden";
    2.16  ["browse the portal as an unregistered user"] = "Die Plattform als nicht-registrierter Benutzer erkunden";
    2.17  ["browse through the competing initiatives"] = "durch die konkurrierenden Initiativen sehen";
    2.18 -["but"] = "aber";
    2.19  ["by"] = "von";
    2.20  ["by A-Z"] = "nach A-Z";
    2.21  ["by Z-A"] = "nach Z-A";
     3.1 --- a/locale/translations.el.lua	Wed Oct 20 16:04:30 2021 +0200
     3.2 +++ b/locale/translations.el.lua	Wed Oct 20 16:21:32 2021 +0200
     3.3 @@ -859,7 +859,7 @@
     3.4  ["all results"] = "όλα τα αποτελέσματα";
     3.5  ["all subject areas"] = "όλες οι περιοχές";
     3.6  ["allow invitation again"] = "Να επιτρέπονται ξανά προσκλήσεις";
     3.7 -["and"] = "και";
     3.8 +["#{opinion} and #{implemented}"] = "#{opinion} και #{implemented}";
     3.9  ["and #{count} more initiatives"] = "και #{count} περισσότερες πρωτοβουλίες";
    3.10  ["area"] = "περιοχή";
    3.11  ["at least #{count} approvals"] = "τουλάχιστον #{count} αποδοχές";
    3.12 @@ -871,7 +871,7 @@
    3.13  ["browse the platform as a guest"] = "δες την πλατφόρμα ως επισκέπτης";
    3.14  ["browse the portal as an unregistered user"] = "εξερεύνησε το πόρταλ ως μη εγγεγραμμένος χρήστης";
    3.15  ["browse through the competing initiatives"] = "δες τις ανταγωνιστικές πρωτοβουλίες";
    3.16 -["but"] = "αλλά";
    3.17 +["#{opinion} but #{implemented}"] = "#{opinion} αλλά #{implemented}";
    3.18  ["by"] = "από";
    3.19  ["by A-Z"] = "ανά A-Z";
    3.20  ["by Z-A"] = "ανά Z-A";
     4.1 --- a/locale/translations.en.lua	Wed Oct 20 16:04:30 2021 +0200
     4.2 +++ b/locale/translations.en.lua	Wed Oct 20 16:21:32 2021 +0200
     4.3 @@ -816,7 +816,8 @@
     4.4  ["all results"] = false;
     4.5  ["all subject areas"] = false;
     4.6  ["allow invitation again"] = false;
     4.7 -["and"] = false;
     4.8 +["#{opinion} and #{implemented}"] = "#{opinion} and #{implemented}";
     4.9 +["#{opinion} but #{implemented}"] = "#{opinion} but #{implemented}";
    4.10  ["and #{count} more initiatives"] = false;
    4.11  ["area"] = false;
    4.12  ["author"] = false;
    4.13 @@ -827,7 +828,6 @@
    4.14  ["browse the platform as a guest"] = false;
    4.15  ["browse the portal as an unregistered user"] = false;
    4.16  ["browse through the competing initiatives"] = false;
    4.17 -["but"] = false;
    4.18  ["by"] = false;
    4.19  ["by A-Z"] = false;
    4.20  ["by Z-A"] = false;
     5.1 --- a/locale/translations.fr.lua	Wed Oct 20 16:04:30 2021 +0200
     5.2 +++ b/locale/translations.fr.lua	Wed Oct 20 16:21:32 2021 +0200
     5.3 @@ -860,7 +860,8 @@
     5.4  ["all results"] = false;
     5.5  ["all subject areas"] = "Tous les domaines";
     5.6  ["allow invitation again"] = "Autoriser l'invitation de nouveau";
     5.7 -["and"] = "et";
     5.8 +["#{opinion} and #{implemented}"] = "#{opinion} et #{implemented}";
     5.9 +["#{opinion} but #{implemented}"] = "#{opinion} mais #{implemented}";
    5.10  ["and #{count} more initiatives"] = "et #{compter} plus d'initiatives";
    5.11  ["area"] = "domaine";
    5.12  ["at least #{count} approvals"] = "au moins #{compter} approvazioni";
    5.13 @@ -872,7 +873,6 @@
    5.14  ["browse the platform as a guest"] = "Naviguer sur la plateforme en tant que visiteur";
    5.15  ["browse the portal as an unregistered user"] = "naviguez dans le portal sans vous authentifier";
    5.16  ["browse through the competing initiatives"] = "Explorer les initiativs alternative";
    5.17 -["but"] = "mais";
    5.18  ["by"] = false;
    5.19  ["by A-Z"] = "de A-Z";
    5.20  ["by Z-A"] = "de Z-A";
     6.1 --- a/locale/translations.it.lua	Wed Oct 20 16:04:30 2021 +0200
     6.2 +++ b/locale/translations.it.lua	Wed Oct 20 16:21:32 2021 +0200
     6.3 @@ -895,7 +895,8 @@
     6.4  ["all results"] = false;
     6.5  ["all subject areas"] = "Tutte aree tematiche";
     6.6  ["allow invitation again"] = "abilita nuovamente inviti";
     6.7 -["and"] = "e";
     6.8 +["#{opinion} and #{implemented}"] = "#{opinion} e #{implemented}";
     6.9 +["#{opinion} but #{implemented}"] = "#{opinion} ma #{implemented}";
    6.10  ["and #{count} more initiatives"] = "ed altre #{count} iniziative";
    6.11  ["area"] = "area";
    6.12  ["at least #{count} approvals"] = "almeno #{count} approvazioni";
    6.13 @@ -907,7 +908,6 @@
    6.14  ["browse the platform as a guest"] = "navigare il portale come utente non registrato";
    6.15  ["browse the portal as an unregistered user"] = "navigare il portale come utente non registrato";
    6.16  ["browse through the competing initiatives"] = "esplora le iniziative alternative";
    6.17 -["but"] = "ma";
    6.18  ["by"] = false;
    6.19  ["by A-Z"] = "da A-Z";
    6.20  ["by Z-A"] = "da Z-A";
     7.1 --- a/locale/translations.ka.lua	Wed Oct 20 16:04:30 2021 +0200
     7.2 +++ b/locale/translations.ka.lua	Wed Oct 20 16:21:32 2021 +0200
     7.3 @@ -767,7 +767,8 @@
     7.4  ["add your support (see above) and rate or write new suggestions (and thereby restrict your support to certain conditions if necessary)"] = "მხარი დაუჭირეთ და შეაფასეთ ან დაწერეთ ახალი შეთავაზება (შესაბამისად შეზღუდეთ თქვენი მხარდაჭერა საჭიროებისამებრ)";
     7.5  ["all issues"] = "ყველა საკითხი";
     7.6  ["allow invitation again"] = "მოწვევაზე ნების დართვა";
     7.7 -["and"] = "და";
     7.8 +["#{opinion} and #{implemented}"] = "#{opinion} და #{implemented}";
     7.9 +["#{opinion} but #{implemented}"] = "#{opinion} მაგრამ #{implemented}";
    7.10  ["and #{count} more initiatives"] = "და #{count} მეტი ინიციატივა";
    7.11  ["area"] = "თემატური სფერო";
    7.12  ["at least #{count} approvals"] = "სულ მცირე #{count} მოწონება";
    7.13 @@ -776,7 +777,6 @@
    7.14  ["avatar/photo"] = "ავატარი/ფოტო";
    7.15  ["block this member"] = "წევრის დაბლოკვა";
    7.16  ["browse through the competing initiatives"] = "გაეცანით კონკურენტ ინიციატივებს";
    7.17 -["but"] = "მაგრამ";
    7.18  ["by A-Z"] = "A-Z მიხედვით";
    7.19  ["by Z-A"] = "Z-A მიხედვით";
    7.20  ["by default only those issues are shown, for which your are eligible to participate (change filters on top of the list)"] = "მხოლოდ იმ საკითხთა ჩამონათვალი ჩანს, სადაც უფლებამოსილი ხართ მონაწილეობა მიიღოთ (შეცვალეთ არსებული პარამეტრები)";
     8.1 --- a/static/js/xhr.js	Wed Oct 20 16:04:30 2021 +0200
     8.2 +++ b/static/js/xhr.js	Wed Oct 20 16:21:32 2021 +0200
     8.3 @@ -70,7 +70,7 @@
     8.4  
     8.5    var degreeText = rateSuggestionDegreeTexts[degree];
     8.6    var fulfilledText = fulfilled ? rateSuggestionFulfilledText : rateSuggestionNotFulfilledText;
     8.7 -  var andButText;
     8.8 +  var textTemplate;
     8.9    var icon;
    8.10    var iconColor;
    8.11    if (
    8.12 @@ -81,12 +81,14 @@
    8.13      if (degree == 2 || degree == -2) { 
    8.14        iconColor = "red";
    8.15      }
    8.16 -    andButText = rateSuggestionButText;
    8.17 +    textTemplate = rateSuggestionButText;
    8.18    } else {
    8.19 -    andButText = rateSuggestionAndText;
    8.20 +    textTemplate = rateSuggestionAndText;
    8.21      icon = "done";
    8.22    }
    8.23 -  var text = degreeText + " " + andButText + " " + fulfilledText;
    8.24 +  textTemplate = textTemplate.replace("#{opinion}", degreeText);
    8.25 +  textTemplate = textTemplate.replace("#{implemented}", fulfilledText);
    8.26 +  var text = textTemplate;
    8.27    if (degree == 0) {
    8.28      text = "";
    8.29      icon = "blank";

Impressum / About Us