]> git.mxchange.org Git - friendica.git/commitdiff
Improved poll texts for different conditions
authorMichael <heluecht@pirati.ca>
Mon, 16 May 2022 06:04:46 +0000 (06:04 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 16 May 2022 06:04:46 +0000 (06:04 +0000)
src/Model/Item.php
view/lang/C/messages.po

index 2435e15c2a2d549c60f8863d9dfe8d24da32fb6d..5b144fb73acbd750b5819cf40f700eef3a08e86a 100644 (file)
@@ -3196,13 +3196,28 @@ class Item
                                $percent = $question['voters'] ? ($option['replies'] / $question['voters'] * 100) : 0;
 
                                $options[$key]['percent'] = $percent;
-                               $options[$key]['vote']    = DI::l10n()->t('%s (%d%s, %d votes)', $option['name'], round($percent, 1), '%', $option['replies']);
+
+                               if ($question['voters'] > 0) {
+                                       $options[$key]['vote'] = DI::l10n()->t('%s (%d%s, %d votes)', $option['name'], round($percent, 1), '%', $option['replies']);
+                               } else {
+                                       $options[$key]['vote'] = DI::l10n()->t('%s (%d votes)', $option['name'], $option['replies']);
+                               }
+                       }
+
+                       if (!empty($question['voters']) && !empty($question['endtime'])) {
+                               $summary = DI::l10n()->t('%d voters. Poll end: %s', $question['voters'], Temporal::getRelativeDate($question['endtime']));
+                       } elseif (!empty($question['voters'])) {
+                               $summary = DI::l10n()->t('%d voters.', $question['voters']);
+                       } elseif (!empty($question['endtime'])) {
+                               $summary = DI::l10n()->t('Poll end: %s', Temporal::getRelativeDate($question['endtime']));
+                       } else {
+                               $summary = '';
                        }
 
                        $content .= Renderer::replaceMacros(Renderer::getMarkupTemplate('content/question.tpl'), [
                                '$question' => $question,
                                '$options'  => $options,
-                               '$summary'  => DI::l10n()->t('%d voters. Poll end: %s', $question['voters'], Temporal::getRelativeDate($question['endtime'])),
+                               '$summary'  => $summary,
                        ]);
        }
                DI::profiler()->stopRecording();
index 3d85ff31d789d7307d2c48825e5a95481910aef6..263d07bd7b8f5dccbae92cff28397ee9519eeb0e 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 2022.05-rc\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2022-05-16 05:29+0000\n"
+"POT-Creation-Date: 2022-05-16 06:01+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -2534,8 +2534,8 @@ msgid ""
 "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:1188 src/Model/Item.php:3243
-#: src/Model/Item.php:3249 src/Model/Item.php:3250
+#: src/Content/Text/BBCode.php:1188 src/Model/Item.php:3258
+#: src/Model/Item.php:3264 src/Model/Item.php:3265
 msgid "Link to source"
 msgstr ""
 
@@ -3738,17 +3738,32 @@ msgstr ""
 msgid "bytes"
 msgstr ""
 
-#: src/Model/Item.php:3199
+#: src/Model/Item.php:3201
 #, php-format
 msgid "%s (%d%s, %d votes)"
 msgstr ""
 
-#: src/Model/Item.php:3205
+#: src/Model/Item.php:3203
+#, php-format
+msgid "%s (%d votes)"
+msgstr ""
+
+#: src/Model/Item.php:3208
 #, php-format
 msgid "%d voters. Poll end: %s"
 msgstr ""
 
-#: src/Model/Item.php:3231 src/Model/Item.php:3232
+#: src/Model/Item.php:3210
+#, php-format
+msgid "%d voters."
+msgstr ""
+
+#: src/Model/Item.php:3212
+#, php-format
+msgid "Poll end: %s"
+msgstr ""
+
+#: src/Model/Item.php:3246 src/Model/Item.php:3247
 msgid "View on separate page"
 msgstr ""