Add namespace names for Atikamekw (atj)
[lhc/web/wiklou.git] / languages / Language.php
index 6a83044..f84e21e 100644 (file)
@@ -203,10 +203,11 @@ class Language {
        /**
         * Create a language object for a given language code
         * @param string $code
+        * @param $fallback boolean Whether we're going through language fallback chain
         * @throws MWException
         * @return Language
         */
-       protected static function newFromCode( $code ) {
+       protected static function newFromCode( $code, $fallback = false ) {
                if ( !Language::isValidCode( $code ) ) {
                        throw new MWException( "Invalid language code \"$code\"" );
                }
@@ -220,7 +221,7 @@ class Language {
                }
 
                // Check if there is a language class for the code
-               $class = self::classFromCode( $code );
+               $class = self::classFromCode( $code, $fallback );
                if ( class_exists( $class ) ) {
                        $lang = new $class;
                        return $lang;
@@ -415,10 +416,10 @@ class Language {
        function __construct() {
                $this->mConverter = new FakeConverter( $this );
                // Set the code to the name of the descendant
-               if ( get_class( $this ) == 'Language' ) {
+               if ( static::class === 'Language' ) {
                        $this->mCode = 'en';
                } else {
-                       $this->mCode = str_replace( '_', '-', strtolower( substr( get_class( $this ), 8 ) ) );
+                       $this->mCode = str_replace( '_', '-', strtolower( substr( static::class, 8 ) ) );
                }
                self::getLocalisationCache();
        }
@@ -725,7 +726,7 @@ class Language {
        }
 
        /**
-        * @return array
+        * @return string[]|bool List of date format preference keys, or false if disabled.
         */
        public function getDatePreferences() {
                return self::$dataCache->getItem( $this->mCode, 'datePreferences' );
@@ -2158,12 +2159,10 @@ class Language {
         * the date preference they're supposed to use, it should be used in
         * all children.
         *
-        *<code>
-        * function timeanddate([...], $format = true) {
-        *      $datePreference = $this->dateFormat($format);
-        * [...]
-        * }
-        *</code>
+        *     function timeanddate([...], $format = true) {
+        *       $datePreference = $this->dateFormat($format);
+        *       [...]
+        *     }
         *
         * @param int|string|bool $usePrefs If true, the user's preference is used
         *   if false, the site/language default is used
@@ -4129,7 +4128,7 @@ class Language {
         * Get the list of variants supported by this language
         * see sample implementation in LanguageZh.php
         *
-        * @return array An array of language codes
+        * @return string[] An array of language codes
         */
        public function getVariants() {
                return $this->mConverter->getVariants();
@@ -4340,10 +4339,11 @@ class Language {
 
        /**
         * @param string $code
+        * @param boolean $fallback Whether we're going through language fallback chain
         * @return string Name of the language class
         */
-       public static function classFromCode( $code ) {
-               if ( $code == 'en' ) {
+       public static function classFromCode( $code, $fallback = true ) {
+               if ( $fallback && $code == 'en' ) {
                        return 'Language';
                } else {
                        return 'Language' . str_replace( '-', '_', ucfirst( $code ) );