Drush Support for extracting strings in the theme files

Created on 28 December 2015, over 8 years ago
Updated 18 April 2023, about 1 year ago

Drush utility currently supports, extracting string translations from modules.
eg : potx multiple --modules=example

Similarly, we can have option for themes as well.

Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

🇮🇳India SwapS

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • 🇳🇱Netherlands Watergate

    I've updated the patch of #16 Drush Support for extracting strings in the theme files Needs work to be compatible with Drupal 10 (and the latest version of Drupal 9).

    The change involves the deprecation of drupal_get_path() in Drupal 9, see https://www.drupal.org/node/2940438 . In case older versions of Drupal should still be supported, instead of $path = \Drupal::service('extension.list.theme')->getPath($theme);, something like $path = function_exists('drupal_get_path') ? drupal_get_path('theme', $theme) : \Drupal::service('extension.list.theme')->getPath($theme); (but in that case this change/fix should also be applied on the code handling extracting string translations from modules).

  • 🇳🇱Netherlands Eric_A

    To facilitate reviewing I created an interdiff between #16 and #19 with git. While #19 applies on HEAD (1.0.0), for #16 I had to go back to 2 commits to Drupal 9 code. The interdiff contained a lot of files. I then removed all the files except the two that are changed by both patches.

    So here's something of an interdiff. I'll try to review later on.

  • 🇳🇱Netherlands Eric_A

    So here's something of an interdiff. I'll try to review later on.

    Right. The two relevant files contained irrelevant hunks from the D9-D10 commits. Removed those manually as well.

  • 🇳🇱Netherlands Eric_A

    I've updated the patch of #16 to be compatible with Drupal 10 (and the latest version of Drupal 9).

    The change involves the deprecation of drupal_get_path() in Drupal 9, see https://www.drupal.org/node/2940438 . In case older versions of Drupal should still be supported, instead of $path = \Drupal::service('extension.list.theme')->getPath($theme);, something like $path = function_exists('drupal_get_path') ? drupal_get_path('theme', $theme) : \Drupal::service('extension.list.theme')->getPath($theme); (but in that case this change/fix should also be applied on the code handling extracting string translations from modules).

    According to the info file, potx is runnable on ^8 || ^9 ||^10. If that were true, then #19 would not be correct is as. However, looking at the code from the D10 compatibility issue it is clear that the new services are already in use since 1.0.0. That code will only run on higher versions of Drupal. According to the referenced change record that would be ^9.3.
    So I guess the ideal way forward is to first tackle the version compatibility issue in a separate issue where the code will either be made more compatible or the info file would be fixed to declare a more restrictive version constraint.
    I'll see if I can create that issue today.

  • Status changed to Needs work about 1 year ago
  • 🇳🇱Netherlands Eric_A

    I've updated the patch of #16 to be compatible with Drupal 10 (and the latest version of Drupal 9).

    Hold on... Aren't *.drush.inc commandfiles only loaded by Drush 8 and earlier? Drush 8 is not compatible with Drupal 10 and Drupal 9. (It's Drupal 8 compatible but not recommended.)
    So it seems then that for Drupal 10 only the new Command class should be touched and the potx.drush.inc should be left alone for those on old Drush and old Drupal.

    https://weitzman.github.io/blog/port-to-drush9
    https://www.drush.org/latest/install/#drupal-compatibility

  • 🇳🇱Netherlands Watergate

    Good point; I think you are right, @Eric_A. However, similar changes were already made in #3285613 (i.e., rewriting the deprecated code in the potx.drush.inc file, but for extracting strings from module files).

    Let's use #3354887 to discuss which core and Drush (combinations) are supported and the most suitable strategy.

Production build 0.69.0 2024