Skip to content

Commit

Permalink
refactor: AuditScoreClassifier translator migration
Browse files Browse the repository at this point in the history
  • Loading branch information
DevDavido committed Dec 20, 2023
1 parent 42d9588 commit 91e48a3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Columns/Filters/AuditScoreClassifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

require PIWIK_INCLUDE_PATH . '/plugins/PerformanceAudit/vendor/autoload.php';

use Piwik\Piwik;
use Piwik\Container\StaticContainer;
use Piwik\Translation\Translator;

class AuditScoreClassifier
{
Expand Down Expand Up @@ -72,12 +73,14 @@ public static function getTooltip(string $metric, string $dataTableName)
$metricCategory = lcfirst($matches[3]);
$ranges = self::RANGES[$metricCategory];

$translator = StaticContainer::get('Piwik\Translation\Translator');

foreach ($ranges as $classification => $boundaries) {
$lowerBoundary = $boundaries[0];
$upperBoundary = $boundaries[1];
$isLastBoundary = $boundaries === end($ranges);
if (self::isInRange($value, $lowerBoundary, $upperBoundary, $isLastBoundary)) {
return nl2br(Piwik::translate('PerformanceAudit_Metrics_Tooltip', [
return nl2br($translator->translate('PerformanceAudit_Metrics_Tooltip', [
$value,
$unitSuffix,
mb_strtoupper($classification),
Expand All @@ -87,7 +90,7 @@ public static function getTooltip(string $metric, string $dataTableName)
}
}

return Piwik::translate('PerformanceAudit_Metrics_Tooltip_OutOfRange', [$value, $unitSuffix]);
return $translator->translate('PerformanceAudit_Metrics_Tooltip_OutOfRange', [$value, $unitSuffix]);
}

/**
Expand Down

0 comments on commit 91e48a3

Please sign in to comment.