Created
August 18, 2011 18:10
-
-
Save Fustrate/1154717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Gets the language string based on index | |
public function get($key, $replacements = array()) | |
{ | |
if (empty($key)) | |
throw new Core_Exception('lang_empty_index_sent'); | |
if (is_array($key)) | |
{ | |
$preserve_key = $key; | |
$search = $this->language_strings; | |
while (($part = array_shift($key)) && isset($search[$part])) | |
$search = $search[$part]; | |
if (is_string($search)) | |
{ | |
if (!empty($replacements)) | |
return vsprintf($search, $replacements); | |
return $search; | |
} | |
return implode('+', $preserve_key); | |
} | |
if ($this->keyExists($key)) | |
{ | |
if (!empty($replacements)) | |
return vsprintf($this->language_strings[$key], $replacements); | |
return $this->language_strings[$key]; | |
} | |
return $key; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment