Skip to content

Commit 4702936

Browse files
author
Dave MacFarlane
committed
[main.tpl] Translate Site List in main template
Translate the site names in the main.tpl template based on the logged in user's locale.
1 parent 1004a8f commit 4702936

3 files changed

Lines changed: 5 additions & 16 deletions

File tree

php/libraries/Site.class.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Site implements
7474
*/
7575
function getCenterName(): string
7676
{
77-
return strval($this->_siteInfo['Name']);
77+
return dgettext("psc", strval($this->_siteInfo['Name']));
7878
}
7979

8080
/**

php/libraries/User.class.inc

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,6 @@ class User extends UserPermissions implements
452452
);
453453
}
454454

455-
/**
456-
* Returns all user's sites in an associative array (CenterID => CenterName)
457-
*
458-
* @return array
459-
*/
460-
function getSiteNamesList(): array
461-
{
462-
$sites = [];
463-
foreach ($this->getSites() as $site) {
464-
$sites[$site->getCenterID()->__toString()] = $site->getCenterName();
465-
}
466-
return $sites;
467-
}
468-
469455
/**
470456
* Returns all user's sites that are StudySites
471457
*

src/Middleware/UserPageDecorationMiddleware.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ function ($a, $b) {
204204
// Retrieve site and project names for tooltips
205205
$tpl_data['user']['SitesTooltip'] = implode(
206206
"<br/>",
207-
$this->user->getSiteNames()
207+
array_map(
208+
fn($site) => $site->getCenterName(),
209+
$this->user->getSites(),
210+
)
208211
);
209212
$tpl_data['user']['ProjectsTooltip'] = implode(
210213
"<br/>",

0 commit comments

Comments
 (0)