]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/L10n.php
New parameter to create a share block for display reasons
[friendica.git] / src / Core / L10n.php
index 430f9e3d5ee11aba26f2868e6ec3f771da69c742..1d8cfa705bae359df110a42d826b28e5e11712a4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -85,10 +85,15 @@ class L10n
         * @var Database
         */
        private $dba;
+       /**
+        * @var IManageConfigValues
+        */
+       private $config;
 
        public function __construct(IManageConfigValues $config, Database $dba, IHandleSessions $session, array $server, array $get)
        {
                $this->dba    = $dba;
+               $this->config = $config;
 
                $this->loadTranslationTable(L10n::detectLanguage($server, $get, $config->get('system', 'language', self::DEFAULT)));
                $this->setSessionVariable($session);
@@ -157,9 +162,9 @@ class L10n
                $a->strings = [];
 
                // load enabled addons strings
-               $addons = $this->dba->select('addon', ['name'], ['installed' => true]);
-               while ($p = $this->dba->fetch($addons)) {
-                       $name = Strings::sanitizeFilePathItem($p['name']);
+               $addons = array_keys($this->config->get('addons') ?? []);
+               foreach ($addons as $addon) {
+                       $name = Strings::sanitizeFilePathItem($addon);
                        if (file_exists(__DIR__ . "/../../addon/$name/lang/$lang/strings.php")) {
                                include __DIR__ . "/../../addon/$name/lang/$lang/strings.php";
                        }
@@ -188,10 +193,10 @@ class L10n
        {
                $lang_variable = $server['HTTP_ACCEPT_LANGUAGE'] ?? null;
 
-               $acceptedLanguages = preg_split('/,\s*/', $lang_variable);
-
-               if (empty($acceptedLanguages)) {
+               if (empty($lang_variable)) {
                        $acceptedLanguages = [];
+               } else {
+                       $acceptedLanguages = preg_split('/,\s*/', $lang_variable);
                }
 
                // Add get as absolute quality accepted language (except this language isn't valid)
@@ -329,7 +334,7 @@ class L10n
                                        // for some languages there is only a single array item
                                        $s = $t[0];
                                }
-                               // if $t is empty, skip it, because empty strings array are indended
+                               // if $t is empty, skip it, because empty strings array are intended
                                // to make string file smaller when there's no translation
                        } else {
                                $s = $t;
@@ -429,32 +434,6 @@ class L10n
                return $ret;
        }
 
-       /**
-        * Load poke verbs
-        *
-        * @return array index is present tense verb
-        *                 value is array containing past tense verb, translation of present, translation of past
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
-        * @hook poke_verbs pokes array
-        */
-       public function getPokeVerbs(): array
-       {
-               // index is present tense verb
-               // value is array containing past tense verb, translation of present, translation of past
-               $arr = [
-                       'poke'   => ['poked', $this->t('poke'), $this->t('poked')],
-                       'ping'   => ['pinged', $this->t('ping'), $this->t('pinged')],
-                       'prod'   => ['prodded', $this->t('prod'), $this->t('prodded')],
-                       'slap'   => ['slapped', $this->t('slap'), $this->t('slapped')],
-                       'finger' => ['fingered', $this->t('finger'), $this->t('fingered')],
-                       'rebuff' => ['rebuffed', $this->t('rebuff'), $this->t('rebuffed')],
-               ];
-
-               Hook::callAll('poke_verbs', $arr);
-
-               return $arr;
-       }
-
        /**
         * Creates a new L10n instance based on the given langauge
         *