Closed (fixed)
Project:
Devel
Version:
8.x-3.x-dev
Component:
devel
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
2 May 2018 at 11:08 UTC
Updated:
22 Nov 2019 at 19:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
brahmjeet789 commentedu have added patch to remove t() to $this->t() used in Drupal best practices, please test it.
Comment #3
brahmjeet789 commentedComment #5
akshay kashyap commentedI have created the patch for this. Please review the patch.
Comment #6
akshay kashyap commentedComment #8
prashant.c@Akshay kashyap and @brahmjeet789
$this->tonly works within the Classes and in Class Objects. So in .install and .module files you won't be able to changet()with$this->t()it will not work.Please re-work on the patch and replace the instance only in case of class and objects if any.
Comment #9
brahmjeet789 commented@prashant as suggested by your comment i added new patch ,please review.
Comment #11
vakulrai commented@Prashant.c Adding a patch which will add $this->t() in controller with classes only.
Comment #12
moshe weitzman commentedNeeds reroll
Comment #13
jonathan1055 commentedAdding parent issue #3081785: [meta] Devel 8.x coding standards messages
Comment #14
ravi.shankar commentedThis issue has been fixed in Devel version 8.x-3.x
Comment #15
jonathan1055 commentedYes you are right, thank you.
It was done as part of #3032580: Replace drupal_set_message() with $this->messenger in existing form/controller classes and committed to 8.x-2.x in April 2019
https://git.drupalcode.org/project/devel/commit/b6419ea
Comment #16
jonathan1055 commentedAh! Only some of the
t( )calls were replaced in that issue, the ones affected by drupal_set_message(). There are others which need replacing, as you can see in the patch #11Take a look at the current full list of coding standards faults as loaded on #3081785: [meta] Devel 8.x coding standards messages and you can see some, for exemple in src/Form/SettingsForm.php and src/Form/ConfigsList.php, both of which were included in the patch #11
Comment #17
ravi.shankar commentedI have fixed this.
Comment #18
jonathan1055 commentedLooks good, thanks for working on this. But you only fixed it for the two example files I named. You need to search the whole of the current full list of coding standards faults and find all the files which have this problem.
Comment #19
ravi.shankar commentedI checked all the files, I didn't find any other file which has this problem.
Comment #20
jonathan1055 commentedIf you search for
t() callsin that text file and you will find 57 matches in 11 files, e.g.and
and in 7 more files.
However, phpunit browser tests are always run in English for the UI to save processing resources, hence we do not need to translate the text on the buttons, just simply remove the call to t() completely for those. See https://www.drupal.org/docs/8/phpunit/phpunit-browser-test-tutorial#t
You can add the fixes to all these 11 files in this patch if you want to, as they all have the same coding standards message. Or you could just add the extra fix for DevelGeneratePermissions.php here, and raise a separate issue to remove the t() calls in those 8 test files.
Comment #21
ravi.shankar commentedI have removed all.
Comment #23
gg24 commented@ravi, I see few tests are failing.
Thanks!
Comment #24
gg24 commentedComment #25
staalex commentedUpdated t calls, removed t calls from tests, added StringTranslationTrait to DevelGeneratePermissions
Comment #26
staalex commentedPatch applied cleanly.
Comment #27
jonathan1055 commentedHi alex.stanciu,
Looks good in general, a major improvement on #21. Thanks for adding the StringTranslationTrait to DevelGeneratePermissions. You also fixed a previously missed call to t() in src/Form/SettingsForm.php
I've done a comparison between patch #21 and patch #25 and spotted a few things:
Nice work though. With the above fixes this should be ready.
Jonathan
Comment #28
staalex commentedHi jonathan1055.
You're absolutely right, my IDE played some tricks on me and I missed those occurences.
I uploaded a new patch, hopefully it'll pass.
Comment #29
staalex commentedComment #30
jonathan1055 commentedThanks. Looks good, you have fixed the 3 points in #27
Comment #31
moshe weitzman commentedLGTM as well.
Comment #32
jonathan1055 commentedOK I will see if I can push this change.
Comment #34
jonathan1055 commentedOK, so the commit worked, my first as Devel maintainer :-) Thanks, everyone who contributed a patch.
However the coding standards report for the branch https://www.drupal.org/pift-ci-job/1465968 says we only reduced the number of warnings by 4. The
t() calls should be avoided in classesmessage was not being generated before, which means the default phpcs configuration is not checking for it. We therefore definitely do need our own phpcs.xml.dist file so that we can specify Drupal and DrupalPractice standards. I will follow that up on #3081785: [meta] Devel 8.x coding standards messages