]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/L10n.php
Add search types
[friendica.git] / src / Core / L10n.php
index dfeeeb041b9f7bb194fe9c1afb7a53adcfd425b4..ae0ed18c3d0a732364bfc5d53ca072f935f253cf 100644 (file)
@@ -6,6 +6,7 @@ namespace Friendica\Core;
 
 use Friendica\BaseObject;
 use Friendica\Database\DBA;
+use Friendica\Util\Strings;
 
 /**
  * Provide Language, Translation, and Localization functions to the application
@@ -90,6 +91,7 @@ class L10n extends BaseObject
        /**
         * @brief Returns the preferred language from the HTTP_ACCEPT_LANGUAGE header
         * @return string The two-letter language code
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
        public static function detectLanguage()
        {
@@ -141,9 +143,10 @@ class L10n extends BaseObject
         *
         * If called repeatedly, it won't save the translation strings again, just load the new ones.
         *
-        * @see popLang()
+        * @see   popLang()
         * @brief Stores the current language strings and load a different language.
         * @param string $lang Language code
+        * @throws \Exception
         */
        public static function pushLang($lang)
        {
@@ -187,9 +190,12 @@ class L10n extends BaseObject
         * Uses an App object shim since all the strings files refer to $a->strings
         *
         * @param string $lang language code to load
+        * @throws \Exception
         */
        private static function loadTranslationTable($lang)
        {
+               $lang = Strings::sanitizeFilePathItem($lang);
+
                if ($lang === self::$lang) {
                        return;
                }
@@ -200,7 +206,7 @@ class L10n extends BaseObject
                // load enabled addons strings
                $addons = DBA::select('addon', ['name'], ['installed' => true]);
                while ($p = DBA::fetch($addons)) {
-                       $name = $p['name'];
+                       $name = Strings::sanitizeFilePathItem($p['name']);
                        if (file_exists("addon/$name/lang/$lang/strings.php")) {
                                include "addon/$name/lang/$lang/strings.php";
                        }
@@ -269,8 +275,9 @@ class L10n extends BaseObject
         *
         * @param string $singular
         * @param string $plural
-        * @param int $count
+        * @param int    $count
         * @return string
+        * @throws \Exception
         */
        public static function tt($singular, $plural, $count)
        {
@@ -314,6 +321,9 @@ class L10n extends BaseObject
 
        /**
         * Provide a fallback which will not collide with a function defined in any language file
+        *
+        * @param int $n
+        * @return bool
         */
        private static function stringPluralSelectDefault($n)
        {
@@ -391,7 +401,8 @@ class L10n extends BaseObject
         * Load poke verbs
         *
         * @return array index is present tense verb
-        *                               value is array containing past tense verb, translation of present, translation of past
+        *                 value is array containing past tense verb, translation of present, translation of past
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @hook poke_verbs pokes array
         */
        public static function getPokeVerbs()