mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
72047aa3a1
commit
a9abe0e6ca
@ -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
|
* @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.
|
* 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);
|
$realEntity = array_pop($entityParts);
|
||||||
$class = implode('.',$entityParts);
|
$class = implode('.',$entityParts);
|
||||||
if(!isset($lang[$locale][$class])) i18n::include_by_class($class);
|
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);
|
return (is_array($transEntity) ? $transEntity[0] : $transEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user