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

Similarly, we can have option for themes as well.

Issue fork potx-2641334

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

SwapS created an issue. See original summary.

swaps’s picture

Issue summary: View changes
swaps’s picture

Patch for the feature request.

Drush command :
drush potx multiple --themes=example

Cheers,
SwapS

swaps’s picture

Assigned: swaps » Unassigned
Status: Active » Needs review
swaps’s picture

Priority: Normal » Major
swaps’s picture

Priority: Major » Critical

Changing the status as couldn't see any update from long.

Thanks,
SwapS

swaps’s picture

Can someone please pick this up ?
It's been in the same state for very long now.

Cheers,
SwapS

interx’s picture

Status: Needs review » Reviewed & tested by the community

The patch still applies on "kgaut/potx": "dev-8.x-1.x".
I tested the patch and it works for me.

drush potx single --themes=my_theme --api=8

Maybe a separate test for the themes options should be added.

ericbellot’s picture

Patch to add Drush Support for extracting strings in the theme files to potx-8.x-dev (commit efe650235717ce2307a5583277f09cacc3642977: 16/02/2018)

Status: Reviewed & tested by the community » Needs work
bramdriesen’s picture

Version: 7.x-3.x-dev » 8.x-1.x-dev

Should be targeted at the D8 version if I'm not mistaken.

marjina-constantin’s picture

First patch does not have drush 9 support, second one is not applying, so I adjusted the code and wrote the third one :)

marjina-constantin’s picture

Status: Needs work » Needs review
floydm’s picture

Patch #12 works great for me, thank you.

My only issue is that it conflicted with another patch I needed on issue #3075494. I combined the two and created a new patch:

https://www.drupal.org/files/issues/2019-09-09/potx-drush_language-30754...

It'd be great to see one or both of these fixes rolled into the dev branch.

gábor hojtsy’s picture

Are the changes Drupal 9 compatible? The 8.x-1.x branch is now Drupal 9 compatible so changes are also supposed to be so. Sending a retest for that.

marjina-constantin’s picture

Reroll of the patch. Changes are Drupal 9 compatible.

duaelfr’s picture

Status: Needs review » Reviewed & tested by the community

I've been using this patch for a few months without problems on a D9 project.
The code looks good.
Thanks!

vodde83 made their first commit to this issue’s fork.

watergate’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new4.08 KB

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).

eric_a’s picture

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 (from the D9-D10 update). 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.

eric_a’s picture

StatusFileSize
new2.15 KB

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.

eric_a’s picture

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.

eric_a’s picture

Status: Needs review » Needs work

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 compatibility only deprecated code in 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

watergate’s picture

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

Let's use #3354887: The potx info file incorrectly claims ^8 || ^9 || 10 core compatibility to discuss which core and Drush (combinations) are supported and the most suitable strategy.

watergate’s picture

I updated the patch to be compatible with the latest version of this module (when using Drupal 10 or 11).

I noticed that #3464392: Create a new 2.0.0 version of POTX has been created mainly to remove support for old/obsolete code. This issue will also become easier when a 2.0.0 version is released.

watergate’s picture

Version: 8.x-1.x-dev » 2.x-dev
Priority: Critical » Normal