X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FL10n.php;h=542590646d4b21e11a77beda055a62a0f666fe25;hb=761bdafa34bfdf1b2b43a3f06ae092e0925898ac;hp=2389817021b2a5bc26e9e511f94ec8a4df7f1ef5;hpb=2fa6cc000013089d59d9cc221b544ed1a7a4cd37;p=friendica.git diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 2389817021..542590646d 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -4,8 +4,9 @@ */ namespace Friendica\Core; -use Friendica\Core\Config; -use dba; +use Friendica\BaseObject; +use Friendica\Database\DBA; +use Friendica\Core\System; require_once 'boot.php'; require_once 'include/dba.php'; @@ -14,7 +15,7 @@ require_once 'include/dba.php'; * Provide Languange, Translation, and Localisation functions to the application * Localisation can be referred to by the numeronym L10N (as in: "L", followed by ten more letters, and then "N"). */ -class L10n extends \Friendica\BaseObject +class L10n extends BaseObject { /** * @brief get the prefered language from the HTTP_ACCEPT_LANGUAGE header @@ -111,8 +112,8 @@ class L10n extends \Friendica\BaseObject $a->strings = []; // load enabled addons strings - $addons = dba::select('addon', ['name'], ['installed' => true]); - while ($p = dba::fetch($addons)) { + $addons = DBA::select('addon', ['name'], ['installed' => true]); + while ($p = DBA::fetch($addons)) { $name = $p['name']; if (file_exists("addon/$name/lang/$lang/strings.php")) { include "addon/$name/lang/$lang/strings.php"; @@ -180,6 +181,12 @@ class L10n extends \Friendica\BaseObject */ public static function tt($singular, $plural, $count) { + $a = self::getApp(); + + if (!is_numeric($count)) { + logger('Non numeric count called by ' . System::callstack(20)); + } + $lang = Config::get('system', 'language'); if (!empty($a->strings[$singular])) { @@ -191,7 +198,13 @@ class L10n extends \Friendica\BaseObject } else { $i = self::stringPluralSelectDefault($count); } - $s = $t[$i]; + + // for some languages there is only a single array item + if (!isset($t[$i])) { + $s = $t[0]; + } else { + $s = $t[$i]; + } } else { $s = $t; }