From f7e9b74dca7b19b21164318b0ab7f537fb271d28 Mon Sep 17 00:00:00 2001
From: Adam Magness <adam.magness@gmail.com>
Date: Tue, 23 Jan 2018 12:47:30 -0500
Subject: [PATCH] Update function and sprintf

Update variable to static function and remove sprintf wrappers
---
 boot.php          | 2 +-
 include/text.php  | 6 +++---
 src/Core/L10n.php | 9 +++++----
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/boot.php b/boot.php
index 58c0cc6c31..0f09d9c56b 100644
--- a/boot.php
+++ b/boot.php
@@ -781,7 +781,7 @@ function run_update_function($x)
 			//send the administrator an e-mail
 			DBStructure::updateFail(
 				$x,
-				sprintf(L10n::t('Update %s failed. See error logs.'), $x)
+				L10n::t('Update %s failed. See error logs.', $x)
 			);
 			return false;
 		} else {
diff --git a/include/text.php b/include/text.php
index a366e78477..ffa0ad0ed6 100644
--- a/include/text.php
+++ b/include/text.php
@@ -952,7 +952,7 @@ function contact_block() {
 				dbesc(implode(",", $contacts)));
 
 			if (DBM::is_result($r)) {
-				$contacts = sprintf(L10n::tt('%d Contact', '%d Contacts', $total), $total);
+				$contacts = L10n::tt('%d Contact', '%d Contacts', $total);
 				$micropro = [];
 				foreach ($r as $rr) {
 					$micropro[] = micropro($rr, true, 'mpfriend');
@@ -1411,7 +1411,7 @@ function prepare_body(&$item, $attach = false, $preview = false) {
 	while ((strpos($s, $spoilersearch) !== false)) {
 		$pos = strpos($s, $spoilersearch);
 		$rnd = random_string(8);
-		$spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" class="spoiler-wrap fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(L10n::t('Click to open/close')) . '</span>'.
+		$spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" class="spoiler-wrap fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . L10n::t('Click to open/close') . '</span>'.
 					'<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">';
 		$s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch));
 	}
@@ -1422,7 +1422,7 @@ function prepare_body(&$item, $attach = false, $preview = false) {
 	while ((strpos($s, $authorsearch) !== false)) {
 		$pos = strpos($s, $authorsearch);
 		$rnd = random_string(8);
-		$authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" class="author-wrap fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . sprintf(L10n::t('Click to open/close')) . '</span>'.
+		$authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" class="author-wrap fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . L10n::t('Click to open/close') . '</span>'.
 					'<blockquote class="author" id="author-' . $rnd . '" style="display: block;">';
 		$s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch));
 	}
diff --git a/src/Core/L10n.php b/src/Core/L10n.php
index be19d546d0..3e9ba3859f 100644
--- a/src/Core/L10n.php
+++ b/src/Core/L10n.php
@@ -115,12 +115,12 @@ class L10n
 		while ($p = dba::fetch($addons)) {
 			$name = $p['name'];
 			if (file_exists("addon/$name/lang/$lang/strings.php")) {
-				include("addon/$name/lang/$lang/strings.php");
+				include "addon/$name/lang/$lang/strings.php";
 			}
 		}
 
 		if (file_exists("view/lang/$lang/strings.php")) {
-			include("view/lang/$lang/strings.php");
+			include "view/lang/$lang/strings.php";
 		}
 	}
 
@@ -184,9 +184,10 @@ class L10n
 			if (is_array($t)) {
 				$plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);
 				if (function_exists($plural_function)) {
-					$plural_function = 'stringPluralSelectDefault';
+					$i = $plural_function($count);
+				} else {
+					$i = self::stringPluralSelectDefault($count);
 				}
-				$i = $plural_function($count);
 				$s = $t[$i];
 			} else {
 				$s = $t;
-- 
2.39.5