Problem/Motivation
format_size()
is still a procedural function. Convert it to a object oriented code.
Proposed resolution
- Add a
::formatByteSize()
method toTranslationInterface
and itsTranslationManager
implementation - Add a
::formatByteSize()
method toStringTranslationTrait
as a helper to accessTranslationManager::formatByteSize
. - Deprecate and remove usages of
format_size()
. - Add related PHP unit tests.
This way any object implementing StringTranslationTrait
(forms, plugins, controllers etc.) can simply replace format_size
with $this->formatByteSize
, while other code (procedural functions, hook implementations, etc) can replace with \Drupal::translation()->formatByteSize
.
Remaining tasks
review/commit
User interface changes
none
API changes
See proposed resolution.