refactor the lang class.
This commit is contained in:
@@ -63,7 +63,10 @@ class Lang {
|
|||||||
*/
|
*/
|
||||||
public function get($language = null, $default = null)
|
public function get($language = null, $default = null)
|
||||||
{
|
{
|
||||||
if (is_null($language)) $language = Config::get('application.language');
|
if (is_null($language))
|
||||||
|
{
|
||||||
|
$language = Config::get('application.language');
|
||||||
|
}
|
||||||
|
|
||||||
list($module, $file, $line) = $this->parse($this->key, $language);
|
list($module, $file, $line) = $this->parse($this->key, $language);
|
||||||
|
|
||||||
@@ -98,9 +101,15 @@ class Lang {
|
|||||||
{
|
{
|
||||||
$module = (strpos($key, '::') !== false) ? substr($key, 0, strpos($key, ':')) : 'application';
|
$module = (strpos($key, '::') !== false) ? substr($key, 0, strpos($key, ':')) : 'application';
|
||||||
|
|
||||||
if ($module != 'application') $key = substr($key, strpos($key, ':') + 2);
|
if ($module != 'application')
|
||||||
|
{
|
||||||
|
$key = substr($key, strpos($key, ':') + 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (count($segments = explode('.', $key)) > 1) return array($module, $segments[0], $segments[1]);
|
if (count($segments = explode('.', $key)) > 1)
|
||||||
|
{
|
||||||
|
return array($module, $segments[0], $segments[1]);
|
||||||
|
}
|
||||||
|
|
||||||
throw new \Exception("Invalid language line [$key]. A specific line must be specified.");
|
throw new \Exception("Invalid language line [$key]. A specific line must be specified.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user