]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/L10n.php
Correct content type
[friendica.git] / src / Core / L10n.php
index 2389817021b2a5bc26e9e511f94ec8a4df7f1ef5..542590646d4b21e11a77beda055a62a0f666fe25 100644 (file)
@@ -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;
                        }