Commit ea6b58b2 authored by Taylor Otwell's avatar Taylor Otwell

refactoring lang class.

parent c5ddb67d
......@@ -28,6 +28,10 @@ class Lang {
/**
* Create a new Lang instance.
*
* Language lines are retrieved using "dot" notation. So, asking for the
* "messages.required" language line would return the "required" line
* from the "messages" language file.
*
* @param string $line
* @return void
*/
......@@ -63,7 +67,6 @@ class Lang {
if ( ! array_key_exists($language.$file, static::$lines))
{
// The language file doesn't exist, return the default value.
$line = is_callable($default) ? call_user_func($default) : $default;
}
else
......@@ -82,13 +85,14 @@ class Lang {
/**
* Parse a language key.
*
* The value on the left side of the dot is the language file name,
* while the right side of the dot is the item within that file.
*
* @param string $key
* @return array
*/
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.
$segments = explode('.', $key);
if (count($segments) < 2)
......@@ -108,13 +112,10 @@ class Lang {
*/
private function load($file, $language)
{
// 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))
if ( ! array_key_exists($language.$file, static::$lines) and file_exists($path = APP_PATH.'lang/'.$language.'/'.$file.EXT))
{
return;
static::$lines[$language.$file] = require $path;
}
static::$lines[$language.$file] = require $path;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment