Skip to content

Instantly share code, notes, and snippets.

@Fustrate
Created August 18, 2011 18:10
Show Gist options
  • Save Fustrate/1154717 to your computer and use it in GitHub Desktop.
Save Fustrate/1154717 to your computer and use it in GitHub Desktop.
// 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