ENHANCEMENT Using $locale in _t() instead of repeatedly calling i18n::get_locale()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@64078 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2008-10-10 17:36:13 +00:00
parent 72047aa3a1
commit a9abe0e6ca

View File

@ -281,7 +281,7 @@ function stripslashes_recursively(&$array) {
}
/**
* This is the main translator function. Returns the string defined by $class and $entity according to the currently set locale
* This is the main translator function. Returns the string defined by $class and $entity according to the currently set locale.
*
* @param string $entity Entity that identifies the string. It must be in the form "Namespace.Entity" where Namespace will be usually
* the class name where this string is used and Entity identifies the string inside the namespace.
@ -301,7 +301,7 @@ function _t($entity, $string = "", $priority = 40, $context = "") {
$realEntity = array_pop($entityParts);
$class = implode('.',$entityParts);
if(!isset($lang[$locale][$class])) i18n::include_by_class($class);
$transEntity = isset($lang[i18n::get_locale()][$class][$realEntity]) ? $lang[i18n::get_locale()][$class][$realEntity] : $string;
$transEntity = isset($lang[$locale][$class][$realEntity]) ? $lang[$locale][$class][$realEntity] : $string;
return (is_array($transEntity) ? $transEntity[0] : $transEntity);
}