]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/L10n.php
Replace global $lang with system.language
[friendica.git] / src / Core / L10n.php
index 24be0109554b2e4ba0a02e98502ffbddc4a83e2a..2389817021b2a5bc26e9e511f94ec8a4df7f1ef5 100644 (file)
@@ -14,7 +14,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
+class L10n extends \Friendica\BaseObject
 {
        /**
         * @brief get the prefered language from the HTTP_ACCEPT_LANGUAGE header
@@ -62,11 +62,11 @@ class L10n
         */
        public static function pushLang($language)
        {
-               global $lang, $a;
+               $a = self::getApp();
 
-               $a->langsave = $lang;
+               $a->langsave = Config::get('system', 'language');
 
-               if ($language === $lang) {
+               if ($language === $a->langsave) {
                        return;
                }
 
@@ -75,7 +75,7 @@ class L10n
                }
                $a->strings = [];
                self::loadTranslationTable($language);
-               $lang = $language;
+               Config::set('system', 'language', $language);
        }
 
        /**
@@ -83,9 +83,9 @@ class L10n
         */
        public static function popLang()
        {
-               global $lang, $a;
+               $a = self::getApp();
 
-               if ($lang === $a->langsave) {
+               if (Config::get('system', 'language') === $a->langsave) {
                        return;
                }
 
@@ -95,7 +95,7 @@ class L10n
                        $a->strings = [];
                }
 
-               $lang = $a->langsave;
+               Config::set('system', 'language', $a->langsave);
        }
 
        /**
@@ -107,7 +107,7 @@ class L10n
         */
        public static function loadTranslationTable($lang)
        {
-               $a = get_app();
+               $a = self::getApp();
 
                $a->strings = [];
                // load enabled addons strings
@@ -142,7 +142,7 @@ class L10n
         */
        public static function t($s, ...$vars)
        {
-               $a = get_app();
+               $a = self::getApp();
 
                if (empty($s)) {
                        return '';
@@ -173,7 +173,6 @@ class L10n
         * - L10n::tt('Like', 'Likes', $count)
         * - L10n::tt("%s user deleted", "%s users deleted", count($users))
         *
-        * @global type $lang
         * @param string $singular
         * @param string $plural
         * @param int $count
@@ -181,10 +180,9 @@ class L10n
         */
        public static function tt($singular, $plural, $count)
        {
-               global $lang;
-               $a = get_app();
+               $lang = Config::get('system', 'language');
 
-               if (x($a->strings, $singular)) {
+               if (!empty($a->strings[$singular])) {
                        $t = $a->strings[$singular];
                        if (is_array($t)) {
                                $plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);