Skip to content

Commit

Permalink
[4.x] Fix unit translations (#9472)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Feb 6, 2024
1 parent 2132729 commit c2495fa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Support/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,23 @@ public static function deslugify($string)
public static function fileSizeForHumans($bytes, $decimals = 2)
{
if ($bytes >= 1073741824) {
return trans_choice('statamic::messages.units.GB', number_format($bytes / 1073741824, $decimals));
return trans('statamic::messages.units.GB', ['count' => number_format($bytes / 1073741824, $decimals)]);
} elseif ($bytes >= 1048576) {
return trans_choice('statamic::messages.units.MB', number_format($bytes / 1048576, $decimals));
return trans('statamic::messages.units.MB', ['count' => number_format($bytes / 1048576, $decimals)]);
} elseif ($bytes >= 1024) {
return trans_choice('statamic::messages.units.KB', number_format($bytes / 1024, $decimals));
return trans('statamic::messages.units.KB', ['count' => number_format($bytes / 1024, $decimals)]);
}

return trans_choice('statamic::messages.units.B', $bytes);
return trans('statamic::messages.units.B', ['count' => $bytes]);
}

public static function timeForHumans($ms)
{
if ($ms < 1000) {
return trans_choice('statamic::messages.units.ms', $ms);
return trans('statamic::messages.units.ms', ['count' => $ms]);
}

return trans_choice('statamic::messages.units.s', round($ms / 1000, 2));
return trans('statamic::messages.units.s', ['count' => round($ms / 1000, 2)]);
}

/**
Expand Down

0 comments on commit c2495fa

Please sign in to comment.