mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Including all translated language tables by default in i18n::_t() instead of selectively including modules based on filename. This caused bugs where entities were located in language tables in a different module than their filepath would suggest. Example: Page.SINGULARNAME is stored in sapphire/lang/en_US.php, while Page.php is stored in mysite/Page.php
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68751 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
70e4faf63f
commit
7f2f047285
@ -811,12 +811,22 @@ class i18n extends Object {
|
||||
*/
|
||||
static function _t($entity, $string = "", $priority = 40, $context = "") {
|
||||
global $lang;
|
||||
|
||||
// get current locale (either default or user preference)
|
||||
$locale = i18n::get_locale();
|
||||
|
||||
// parse $entity into its parts
|
||||
$entityParts = explode('.',$entity);
|
||||
$realEntity = array_pop($entityParts);
|
||||
$class = implode('.',$entityParts);
|
||||
if(!isset($lang[$locale][$class])) i18n::include_by_class($class);
|
||||
|
||||
// if language table isn't loaded for this locale, get it for each of the modules
|
||||
if(!isset($lang[$locale])) i18n::include_by_locale($locale);
|
||||
|
||||
// fallback to the passed $string if no translation is present
|
||||
$transEntity = isset($lang[$locale][$class][$realEntity]) ? $lang[$locale][$class][$realEntity] : $string;
|
||||
|
||||
// entities can be stored in both array and literal values in the language tables
|
||||
return (is_array($transEntity) ? $transEntity[0] : $transEntity);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user