diff --git a/system/lang.php b/system/lang.php index d74fd017..ad220d89 100644 --- a/system/lang.php +++ b/system/lang.php @@ -61,31 +61,16 @@ public function get($default = null) $this->load($file, $language); - // -------------------------------------------------------------- - // If the language file did not exist, return the default value. - // -------------------------------------------------------------- if ( ! array_key_exists($language.$file, static::$lines)) { - return $default; - } - - // -------------------------------------------------------------- - // Get the language line from the appropriate file array. - // If the line doesn't exist, return the default value. - // -------------------------------------------------------------- - if (array_key_exists($line, static::$lines[$language.$file])) - { - $line = static::$lines[$language.$file][$line]; + // The language file doesn't exist, return the default value. + $line = is_callable($default) ? call_user_func($default) : $default; } else { - return $default; + $line = Arr::get(static::$lines[$language.$file], $line, $default); } - // -------------------------------------------------------------- - // Make all place-holder replacements. Place-holders are prefixed - // with a colon for convenient location. - // -------------------------------------------------------------- foreach ($this->replacements as $key => $value) { $line = str_replace(':'.$key, $value, $line); @@ -102,10 +87,8 @@ public function get($default = null) */ private function parse($key) { - // -------------------------------------------------------------- - // The left side of the dot is the file name, while the right - // side of the dot is the item within that file being requested. - // -------------------------------------------------------------- + // The left side of the dot is the file name, while the right side of the dot + // is the item within that file being requested. $segments = explode('.', $key); if (count($segments) < 2) @@ -125,10 +108,7 @@ private function parse($key) */ private function load($file, $language) { - // -------------------------------------------------------------- - // If we have already loaded the language file or the file - // doesn't exist, bail out. - // -------------------------------------------------------------- + // If we have already loaded the language file or the file doesn't exist, bail out. if (array_key_exists($language.$file, static::$lines) or ! file_exists($path = APP_PATH.'lang/'.$language.'/'.$file.EXT)) { return;