From 386c586b380868c83558c3c9e981bd9b0563e99c Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 2 Nov 2008 22:45:49 +0000 Subject: [PATCH] BUGFIX Setting menu titles for CMSMenu items in LeftAndMain::init() to get translated values for the current user locale (see #2873) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@65106 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 6466c991..ba80275e 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -329,8 +329,18 @@ class LeftAndMain extends Controller { } } + // already set in CMSMenu::populate_menu(), but from a static pre-controller + // context, so doesn't respect the current user locale in _t() calls - as a workaround, + // we simply call getMenuTitle() again if we're dealing with a controller + if($menuItem->controller) { + $controllerObj = singleton($menuItem->controller); + $title = $controllerObj->getMenuTitle(); + } else { + $title = $menuItem->title; + } + $menu->push(new ArrayData(array( - "Title" => Convert::raw2xml($menuItem->title), + "Title" => Convert::raw2xml($title), "Code" => $code, "Link" => $menuItem->url, "LinkingMode" => $linkingmode