# HG changeset patch # User bsw # Date 1634739692 -7200 # Node ID fe28be5403e243ec5a1054b6811d4d75a164c5fa # Parent 4edec387855ff62cdc355216fbdfe6d559894cd7 Better handling of combined sentence on suggestion rating diff -r 4edec387855f -r fe28be5403e2 app/main/initiative/_suggestions.lua --- a/app/main/initiative/_suggestions.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/app/main/initiative/_suggestions.lua Wed Oct 20 16:21:32 2021 +0200 @@ -251,37 +251,38 @@ if direct_supporter then ui.container{ attr = { class = "suggestion_rating_info" }, content = function() ui.tag{ attr = { id = "s" .. suggestion.id .. "_rating_text" }, content = function() - local text = "" + local text_opinion = "" if opinion then - if opinion.degree == 2 then - text = _"must" - elseif opinion.degree == 1 then - text = _"should" - elseif opinion.degree == 0 then - text = _"neutral" - elseif opinion.degree == -1 then - text = _"should not" - elseif opinion.degree == -2 then - text = _"must not" - end - ui.tag { content = text } - slot.put ( " " ) + local text_template if (opinion.degree > 0 and not opinion.fulfilled) or (opinion.degree < 0 and opinion.fulfilled) then - ui.tag{ content = _"but" } + text_template = _"#{opinion} but #{implemented}" else - ui.tag{ content = _"and" } + text_template = _"#{opinion} and #{implemented}" end - slot.put ( " " ) - local text = "" + if opinion.degree == 2 then + text_opinion = _"must" + elseif opinion.degree == 1 then + text_opinion = _"should" + elseif opinion.degree == 0 then + text_opinion = _"neutral" + elseif opinion.degree == -1 then + text_opinion = _"should not" + elseif opinion.degree == -2 then + text_opinion = _"must not" + end + local text_implemented = "" if opinion.fulfilled then - text = _"is implemented" + text_implemented = _"is implemented" else - text = _"is not implemented" + text_implemented = _"is not implemented" end - ui.tag { content = text } + ui.tag { content = _(text_template, { + opinion = text_opinion, + implemented = text_implemented + }) } end end } local id = "s" .. suggestion.id .. "_rating_icon" @@ -332,14 +333,14 @@ ui.script{ script = [[ var rateSuggestionRateText = "]] .. _"rate suggestion" .. [["; var rateSuggestionUpdateRatingText = "]] .. _"update rating" .. [["; + var rateSuggestionAndText = "]] .. _"#{opinion} and #{implemented}" .. [["; + var rateSuggestionButText = "]] .. _"#{opinion} but #{implemented}" .. [["; var rateSuggestionDegreeTexts = { "-2": "]] .. _"must not" .. [[", "-1": "]] .. _"should not" .. [[", "1": "]] .. _"should" .. [[", "2": "]] .. _"must" .. [[" } - var rateSuggestionAndText = "]] .. _"and" .. [["; - var rateSuggestionButText = "]] .. _"but" .. [["; var rateSuggestionFulfilledText = "]] .. _"is implemented" .. [["; var rateSuggestionNotFulfilledText = "]] .. _"is not implemented" .. [["; window.addEventListener("load", function() { diff -r 4edec387855f -r fe28be5403e2 locale/translations.de.lua --- a/locale/translations.de.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/locale/translations.de.lua Wed Oct 20 16:21:32 2021 +0200 @@ -861,8 +861,9 @@ ["all results"] = "Alle Ergebnisse"; ["all subject areas"] = "Alle Themenbereiche"; ["allow invitation again"] = "Einladen wieder erlauben"; -["and"] = "und"; ["and #{count} more initiatives"] = "und #{count} weitere Initiativen"; +["#{opinion} and #{implemented}"] = "#{opinion} und #{implemented}"; +["#{opinion} but #{implemented}"] = "#{opinion} aber #{implemented}"; ["area"] = "Themenbereich"; ["at least #{count} approvals"] = "mindestens #{count} Zustimmungen"; ["at least #{count} approvals or abstentions"] = "mindestens #{count} Zustimmungen oder Enthaltungen"; @@ -873,7 +874,6 @@ ["browse the platform as a guest"] = "Die Plattform als Gast erkunden"; ["browse the portal as an unregistered user"] = "Die Plattform als nicht-registrierter Benutzer erkunden"; ["browse through the competing initiatives"] = "durch die konkurrierenden Initiativen sehen"; -["but"] = "aber"; ["by"] = "von"; ["by A-Z"] = "nach A-Z"; ["by Z-A"] = "nach Z-A"; diff -r 4edec387855f -r fe28be5403e2 locale/translations.el.lua --- a/locale/translations.el.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/locale/translations.el.lua Wed Oct 20 16:21:32 2021 +0200 @@ -859,7 +859,7 @@ ["all results"] = "όλα τα αποτελέσματα"; ["all subject areas"] = "όλες οι περιοχές"; ["allow invitation again"] = "Να επιτρέπονται ξανά προσκλήσεις"; -["and"] = "και"; +["#{opinion} and #{implemented}"] = "#{opinion} και #{implemented}"; ["and #{count} more initiatives"] = "και #{count} περισσότερες πρωτοβουλίες"; ["area"] = "περιοχή"; ["at least #{count} approvals"] = "τουλάχιστον #{count} αποδοχές"; @@ -871,7 +871,7 @@ ["browse the platform as a guest"] = "δες την πλατφόρμα ως επισκέπτης"; ["browse the portal as an unregistered user"] = "εξερεύνησε το πόρταλ ως μη εγγεγραμμένος χρήστης"; ["browse through the competing initiatives"] = "δες τις ανταγωνιστικές πρωτοβουλίες"; -["but"] = "αλλά"; +["#{opinion} but #{implemented}"] = "#{opinion} αλλά #{implemented}"; ["by"] = "από"; ["by A-Z"] = "ανά A-Z"; ["by Z-A"] = "ανά Z-A"; diff -r 4edec387855f -r fe28be5403e2 locale/translations.en.lua --- a/locale/translations.en.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/locale/translations.en.lua Wed Oct 20 16:21:32 2021 +0200 @@ -816,7 +816,8 @@ ["all results"] = false; ["all subject areas"] = false; ["allow invitation again"] = false; -["and"] = false; +["#{opinion} and #{implemented}"] = "#{opinion} and #{implemented}"; +["#{opinion} but #{implemented}"] = "#{opinion} but #{implemented}"; ["and #{count} more initiatives"] = false; ["area"] = false; ["author"] = false; @@ -827,7 +828,6 @@ ["browse the platform as a guest"] = false; ["browse the portal as an unregistered user"] = false; ["browse through the competing initiatives"] = false; -["but"] = false; ["by"] = false; ["by A-Z"] = false; ["by Z-A"] = false; diff -r 4edec387855f -r fe28be5403e2 locale/translations.fr.lua --- a/locale/translations.fr.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/locale/translations.fr.lua Wed Oct 20 16:21:32 2021 +0200 @@ -860,7 +860,8 @@ ["all results"] = false; ["all subject areas"] = "Tous les domaines"; ["allow invitation again"] = "Autoriser l'invitation de nouveau"; -["and"] = "et"; +["#{opinion} and #{implemented}"] = "#{opinion} et #{implemented}"; +["#{opinion} but #{implemented}"] = "#{opinion} mais #{implemented}"; ["and #{count} more initiatives"] = "et #{compter} plus d'initiatives"; ["area"] = "domaine"; ["at least #{count} approvals"] = "au moins #{compter} approvazioni"; @@ -872,7 +873,6 @@ ["browse the platform as a guest"] = "Naviguer sur la plateforme en tant que visiteur"; ["browse the portal as an unregistered user"] = "naviguez dans le portal sans vous authentifier"; ["browse through the competing initiatives"] = "Explorer les initiativs alternative"; -["but"] = "mais"; ["by"] = false; ["by A-Z"] = "de A-Z"; ["by Z-A"] = "de Z-A"; diff -r 4edec387855f -r fe28be5403e2 locale/translations.it.lua --- a/locale/translations.it.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/locale/translations.it.lua Wed Oct 20 16:21:32 2021 +0200 @@ -895,7 +895,8 @@ ["all results"] = false; ["all subject areas"] = "Tutte aree tematiche"; ["allow invitation again"] = "abilita nuovamente inviti"; -["and"] = "e"; +["#{opinion} and #{implemented}"] = "#{opinion} e #{implemented}"; +["#{opinion} but #{implemented}"] = "#{opinion} ma #{implemented}"; ["and #{count} more initiatives"] = "ed altre #{count} iniziative"; ["area"] = "area"; ["at least #{count} approvals"] = "almeno #{count} approvazioni"; @@ -907,7 +908,6 @@ ["browse the platform as a guest"] = "navigare il portale come utente non registrato"; ["browse the portal as an unregistered user"] = "navigare il portale come utente non registrato"; ["browse through the competing initiatives"] = "esplora le iniziative alternative"; -["but"] = "ma"; ["by"] = false; ["by A-Z"] = "da A-Z"; ["by Z-A"] = "da Z-A"; diff -r 4edec387855f -r fe28be5403e2 locale/translations.ka.lua --- a/locale/translations.ka.lua Wed Oct 20 16:04:30 2021 +0200 +++ b/locale/translations.ka.lua Wed Oct 20 16:21:32 2021 +0200 @@ -767,7 +767,8 @@ ["add your support (see above) and rate or write new suggestions (and thereby restrict your support to certain conditions if necessary)"] = "მხარი დაუჭირეთ და შეაფასეთ ან დაწერეთ ახალი შეთავაზება (შესაბამისად შეზღუდეთ თქვენი მხარდაჭერა საჭიროებისამებრ)"; ["all issues"] = "ყველა საკითხი"; ["allow invitation again"] = "მოწვევაზე ნების დართვა"; -["and"] = "და"; +["#{opinion} and #{implemented}"] = "#{opinion} და #{implemented}"; +["#{opinion} but #{implemented}"] = "#{opinion} მაგრამ #{implemented}"; ["and #{count} more initiatives"] = "და #{count} მეტი ინიციატივა"; ["area"] = "თემატური სფერო"; ["at least #{count} approvals"] = "სულ მცირე #{count} მოწონება"; @@ -776,7 +777,6 @@ ["avatar/photo"] = "ავატარი/ფოტო"; ["block this member"] = "წევრის დაბლოკვა"; ["browse through the competing initiatives"] = "გაეცანით კონკურენტ ინიციატივებს"; -["but"] = "მაგრამ"; ["by A-Z"] = "A-Z მიხედვით"; ["by Z-A"] = "Z-A მიხედვით"; ["by default only those issues are shown, for which your are eligible to participate (change filters on top of the list)"] = "მხოლოდ იმ საკითხთა ჩამონათვალი ჩანს, სადაც უფლებამოსილი ხართ მონაწილეობა მიიღოთ (შეცვალეთ არსებული პარამეტრები)"; diff -r 4edec387855f -r fe28be5403e2 static/js/xhr.js --- a/static/js/xhr.js Wed Oct 20 16:04:30 2021 +0200 +++ b/static/js/xhr.js Wed Oct 20 16:21:32 2021 +0200 @@ -70,7 +70,7 @@ var degreeText = rateSuggestionDegreeTexts[degree]; var fulfilledText = fulfilled ? rateSuggestionFulfilledText : rateSuggestionNotFulfilledText; - var andButText; + var textTemplate; var icon; var iconColor; if ( @@ -81,12 +81,14 @@ if (degree == 2 || degree == -2) { iconColor = "red"; } - andButText = rateSuggestionButText; + textTemplate = rateSuggestionButText; } else { - andButText = rateSuggestionAndText; + textTemplate = rateSuggestionAndText; icon = "done"; } - var text = degreeText + " " + andButText + " " + fulfilledText; + textTemplate = textTemplate.replace("#{opinion}", degreeText); + textTemplate = textTemplate.replace("#{implemented}", fulfilledText); + var text = textTemplate; if (degree == 0) { text = ""; icon = "blank";