<?php
namespace Illuminate\Translation;
// set namespace
class ArrayLoader implements LoaderInterface
{// a arrayloader to implements loader Interface
/**
* All of the translation messages.
*
* @var array
*/
protected $messages = [];// the big store to save the message
/**
* 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)
{// load the messages for the given locale.
$namespace = $namespace ?: '*';//set the default namespace
if (isset($this->messages[$namespace][$locale][$group])) {// if set then return it
return $this->messages[$namespace][$locale][$group];
}
return [];//default return null
}
/**
* Add a new namespace to the loader.
*
* @param string $namespace
* @param string $hint
* @return void
*/
public function addNamespace($namespace, $hint)
{
//
}//Add a new namespace to the loader
/**
* Add messages to the loader.
*
* @param string $locale
* @param string $group
* @param array $messages
* @param string|null $namespace
* @return $this
*/
public function addMessages($locale, $group, array $messages, $namespace = null)
{// Add messages to the loader
$namespace = $namespace ?: '*';//set the default namespace
$this->messages[$namespace][$locale][$group] = $messages;// set the message
return $this;// return this instance
}
}
[李景山php]每天laravel-20161024|ArrayLoader.php
原创
©著作权归作者所有:来自51CTO博客作者lijingshan34的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章