t() functions inside classes must reference to current object of class, Hence we must replace t() inside classes with $this->t().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | replace_usage_of_t-2806563-2.patch | 5.54 KB | kunalkursija |
t() functions inside classes must reference to current object of class, Hence we must replace t() inside classes with $this->t().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | replace_usage_of_t-2806563-2.patch | 5.54 KB | kunalkursija |
Comments
Comment #2
kunalkursija commentedAdding patch.
Comment #3
kunalkursija commentedComment #4
dpacassiTested it on
8.2.x-dev, everything works as expected.Also searched for other
t()occurrences in the action module but wasn't able to find any wrong ones.Comment #5
xjmThank you for your work on cleaning up Drupal core's use of deprecated APIs!
In order to deprecate APIs in a maintainable way, converting deprecated uses should be replaced across all of core for a given kind of usage, rather than in individual modules or files. Such issues should also always be part of an overall plan to ensure all usages are removed, rather than standalone patches. Such a plan may already exist for
t()so this issue should probably be closed in favor of that.For background information on why we usually will not commit cleanups that aren't scoped in that way, see the core issue scope guidelines. See #2575081: [policy, no patch] Use E_USER_DEPRECATED in Drupal 8 minor releases for more information on how we plan to manage deprecations in the future.
Contributing to the overall plan above will help ensure that your cleanups for core's deprecated code improve core in a maintainable and minimally disruptive way.
For this issue, we should start by replacing non-test
t()usages in all classes where the translation trait or service is already available. This can be done with a script. We would then have a followup to inject the service in classes where it is not already available and convert usages there. Finally, we should have a separate issue to discuss the use oft()in tests. We probably should close this issue as a duplicate, but setting to needs work for now so that contributors see this information. Thanks!You might want to help contribute to this issue instead: #2549805: [Meta] Remove all usage of FormattableMarkup in tests apart from explicit tests of that API
Comment #12
amateescu commentedClosing in favor of #2549805: [Meta] Remove all usage of FormattableMarkup in tests apart from explicit tests of that API.