Some modules uses a third party software. For example, the print module uses tcpdf (optional), the fckeditor module uses fckeditor, etc. When a user select "extract all from sub directory" this causes a memory limit problem is some cases, because these third party softwares are too big, and the potx scan these files too. I think, a good solution is adding a new textarea to the potx administrative interface for exclude these subdirectiories from the extraction.

Comments

Gábor Hojtsy’s picture

Well, agreed that this is indeed a problem, and potx should either (1) be more smart in what files it considers for parsing and/or (2) provide a way to manually exclude stuff.

mattyoung’s picture

This can be done by implementing the hook_potx() idea. Potx look for a file name 'mymodule.potx.php', include this file and look for a fucntion mymodule_potx() to execute. That hook_potx() function should return an array telling potx what to do, something like this:

function mymodule_potx() {
  return array(
    'exclude_mask' => 'fckeditor, *.js',   //  <<== this mask should be added to the default file_scan_directory $nomask
    'some_other_feature' => ....
}
Gábor Hojtsy’s picture

*.js is not going to be excluded, since it can contain translatable strings, as long as if it is a Drupal JS file that is.

mattyoung’s picture

That's just "for example", the main thing is the hook_potx() idea. Please ignore that '*.js'. It should be 'somespecific.js'. But the idea is it's a mask, you can specify whatever.

jcnventura’s picture

The exclusion rule should not be determined by the module, as the third-party directory location (and name) are decided by the end-user. Like the coder module, this should accept a list of paths to exclude.

Gábor Hojtsy’s picture

Title: Exclude subdirectiories » Implement Drupal 7 files[] .info file keys as potx parsing hints

In fact, Drupal 7 introduces a mandatory file listing requirement in .info files, so that you need to list all the files your module is composed of. That basically whitelists files that potx should look at (instead of the suggestion here to blacklist them). See http://drupal.org/node/224333#registry

Ideally we should be able to implement this the same way, and just tell people that potx uses the same Drupal 7 syntax in Drupal 6 as well. Additional keys in Drupal 6 info files should not generally be a problem, and Drupal 6 should pick up unknown tags and put them into the parsed structure; but this should be tested for sure.

Using this would also solve identifying files belonging to certain modules, when they are in the same directory. Two problems solved at once with a forwards compatible and non-intrusive way :) Sounds great to me.

Gábor Hojtsy’s picture

To be clear, I'd imagine that we progressively introduce this feature. If a module has files[] keys in its .info file, we skip looking for files based on our patterns. If it does not have these keys, we keep using our pattern based ways.

The missing piece I can think of right now is the .js files, which will not be in the files[] list. Would be good to have something like the styles[] array just names "scripts[]" or somesuch.

Gábor Hojtsy’s picture

Status: Active » Closed (duplicate)

Drupal 8 now has a standard solution for this, the vendor directory. You should include 3rd party software in a vendor directory. See #2027451: Don't go into the vendor directory for Drupal 8. Potx will now skip stuff in that directory.