亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

FileLoader.php

標簽:
PHP

<?php

 

namespace Illuminate\Translation;

 

use Illuminate\Filesystem\Filesystem;

 

class FileLoader implements LoaderInterface

{// FileLoader implements Loader Interface

    /**

     * The filesystem instance.

     *

     * @var \Illuminate\Filesystem\Filesystem

     */

    protected $files;//The filesystem instance.

 

    /**

     * The default path for the loader.

     *

     * @var string

     */

    protected $path;//The default path for the loader.

 

    /**

     * All of the namespace hints.

     *

     * @var array

     */

    protected $hints = [];// All of the namespace hints.

 

    /**

     * Create a new file loader instance.

     *

     * @param  \Illuminate\Filesystem\Filesystem  $files

     * @param  string  $path

     * @return void

     */

    public function __construct(Filesystem $files, $path)

    {

        $this->path = $path;// path

        $this->files = $files;// files

    }//Create a new file loader instance.

 

    /**

     * Load the messages for the given locale.

     *

     * @param  string  $locale

     * @param  string  $group

     * @param  string  $namespace

     * @return array

     */

    public function load($locale, $group, $namespace = null)

    {

        if (is_null($namespace) || $namespace == '*') {

            return $this->loadPath($this->path, $locale, $group);// two type,one is loadPath

        }//locale group and namespace

 

        return $this->loadNamespaced($locale, $group, $namespace);// Load Namespace

    }//Load the messages for the given locale.

 

    /**

     * Load a namespaced translation group.

     *

     * @param  string  $locale

     * @param  string  $group

     * @param  string  $namespace

     * @return array

     */

    protected function loadNamespaced($locale, $group, $namespace)

    {//Load a namespaced translation group

        if (isset($this->hints[$namespace])) {// if it is set

            $lines = $this->loadPath($this->hints[$namespace], $locale, $group);//get this line

 

            return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace);// return a wrap function

        }

 

        return [];//default null

    }

 

    /**

     * Load a local namespaced translation group for overrides.

     *

     * @param  array  $lines

     * @param  string  $locale

     * @param  string  $group

     * @param  string  $namespace

     * @return array

     */

    protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace)

    {//another load space

        $file = "{$this->path}/vendor/{$namespace}/{$locale}/{$group}.php";//get this file

 

        if ($this->files->exists($file)) {// if it is exists

            return array_replace_recursive($lines, $this->files->getRequire($file));

        }// return this thing

 

        return $lines;// return line

    }

 

    /**

     * Load a locale from a given path.

     *

     * @param  string  $path

     * @param  string  $locale

     * @param  string  $group

     * @return array

     */

    protected function loadPath($path, $locale, $group)

    {

        if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) {

            return $this->files->getRequire($full);

        }// like include file by path ,the full is the full path

 

        return [];// null

    }//load a locale from a given path

 

    /**

     * Add a new namespace to the loader.

     *

     * @param  string  $namespace

     * @param  string  $hint

     * @return void

     */

    public function addNamespace($namespace, $hint)

    {

        $this->hints[$namespace] = $hint;

    }// addNamespace

   //Add a new namespace to the loader

}


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消