Closed (fixed)
Project:
Translation template extractor
Version:
7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
21 Feb 2010 at 14:46 UTC
Updated:
27 Sep 2014 at 23:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gábor hojtsyThe command line script does not run in the context of the website, so it does not have a connection to the database. Therefore it is not currently possible to get translations in the command line version.
We can however migrate the command line script to be a drush (http://drupal.org/project/drush) command instead, which could then access the database. Basically no need to keep our own command line wrapper when we can just reuse drush :) Retitled issue for this.
Comment #2
gábor hojtsyHere is a quick attempt at adding this feature. It adds a potx.drush.inc to run with drush in place of the potx-cli.php that was the standalone executable. Since now we have the full potx runtime in the Drupal directory, we need to exclude all the files from potx, so the self-skipper also needed updating.
The current status reporting does direct output printing, not using drush_print(). Not sure how big of an issue is that. Reviews are welcome!
Ps. this only rebuilds the existing functionality as a drush script, and then we can extend this with support for exporting translations in .po files. It should be pretty trivial beyond this patch :)
Ps. we will also need to update the README to reflect this new way of command line support.
Comment #3
gábor hojtsyBTW the drush command help looks like this
Comment #4
moshe weitzman commentedYou want to enrich potx_drush_command() with the available arguments, options, and examples. See core commands for an example. basically, move info from unstructured help hook to potx_drush_command().
Comment #5
dmadruga commentedSubscribe.
Comment #6
gábor hojtsyI'm also thinking we should tap into Drupal's knowledge of modules and take a module name instead of a file path to traverse. eg. instead of
drush potx single sites/all/modules/ogI'd dodrush potx single devel. I'd love to start out with an extensible way to do things, so I'm a bit reluctant to commit this patch right away. We need some "command design" here, or UX for the command line in other words, so we will not end up with broken scheduled jobs with people if we change command syntax. How is this handled in other drush supportive projects? Am I overly cautious?Comment #7
dave reidDrush integration and #6 would be great steps forward here. I bet we could figure out some kind of backwards compatibility for the command that would add a warning about transitioning to the new command format.
Comment #8
cyberwolf commentedWould be a great feature! +1
Comment #9
pbuyle commented#2: potx-drush.patch queued for re-testing.
Comment #11
zilverdistel commentedsubscribing
Comment #12
gábor hojtsyOpened a 7.x-2.x branch for the module to do more drastic feature reorganization / API changes / API cleanup. Removed the potx-cli.php file from that branch in preparation of including actual drush support. There is no excuse for supporting a one-off obscure command line PHP thing... This will hopefully eventually be backported to Drupal 6 too, but currently on 7.x-2.x now. Will work on including the drush support code later.
Comment #13
neurojavi commentedsubscribe
Comment #14
xen commentedsubscribe
Comment #15
jsagotsky commentedsubscribe
Comment #16
zilverdistel commented@Gábor Hojtsy: what's the status on this?
Comment #17
coltranePer conversation with @Gábor Hojtsy I've re-rolled #2 for 6.x-3.x. Have also added Drush command options 'files' and 'modules' so you can pass specific files or module names. Passing neither uses drush_cwd() to extract strings from files in the current directory.
Here's the output of drush help potx:
A little long but wasn't sure whether to put mode as a command option or keep it as an argument.
Comment #18
coltraneQuick update with drush_print() instead of potx_status().
Comment #20
coltraneRetry
Comment #21
coltraneBah, hadn't merged latest 6.x-3.x commit, sorry. This is better.
Comment #22
gábor hojtsyThis looks pretty cool in itself. I think we should take a folder option as well and an API version option. The combination of these would allow us to parse the Drupal 8 codebase from a Drupal 6 setup for example so long as they are on the same filesystem.
Comment #23
coltraneFix for build mode bug and now supporting options folder and api:
Comment #24
gábor hojtsyAmazing, committed! Fabulous!
Comment #25
coltraneExpanded patch for call _potx_process_file() to pass $api_option
Comment #26
coltraneWoops! Here's the updated patch, fixes case where api_option isn't sent to file processing.
Comment #27
gábor hojtsySuperb, thanks! Committed.
Comment #28
gábor hojtsyShould be on 7.x-2.x too of course :)
Comment #29
s_leu commentedOk here's a reroll for 7.x-2.x . Well actually it's more or less a complete rewrite since the API's in 7.x-2.x are quite different. Please check if everything is appropriate.
Comment #30
s_leu commentedForgot to remove some debug statement. Or would it maybe make sense to implement verbosing as a feature/drush option?
Comment #31
eelkeblokI was hoping to add the module as a custom command to my general drush installation, removing the requirement to install the module in every site I want to extract translation strings for and just have it available as a generic drush command. I placed the contents of the module directory in the commands directory of my drush installation (/usr/share/php/drush/commands/potx) and called 'drush potx' just to see what happens. Unfortunately, it broke:
Unfortunately, I don't have time to debug right now, but I thought I'd let you know. This is with the patch from #30.
Comment #32
eelkeblokI figured the fix might be fairly simple, and it was. I replaced the call to drupal_get_path with a call to dirname(__FILE__). Attached is the updated patch.
Comment #34
eelkeblokNot sure why the last patch failed testing, it must've been against a later version of the repository. I've changed it so it only differs from the one in #30 for the one line that changes the call to drupal_get_path() into a call to dirname(__FILE__).
Comment #35
eelkeblokComment #36
eelkeblokIt looks like the extractor will repeat the extracted strings multiple times. The behavour I observed for a .pages.inc (file A), .module (file B) and .info (file C) files:
Strings for file A
Strings for file A
Strings for file B
Strings for file A
Strings for file B
Strings for file C
Strings for file A
Strings for file B
Strings for file C
Strings for file A
Strings for file B
Strings for file C
This may be slightly off, but I think what may be going on is that for each file it scans, it will also include the strings for the previous files. The directory I scanned contains a few more files, they just don't include translatable strings. I'm not certain if this is an issue with the drush patch, or with the extractor itself (I looked for any existing issues, but didn't see any). Maybe somebody can run with this info and provide another patch.
Comment #37
jun commentedHere's a patch based on #34 which outputs the pot files in the directory where drush is ran if no module options are provided and also outputs the path of each created file (previously the files where all created at the webroot and I couldn't find them!). Also when ran with the multiple option, the file name is now the trailing directory name with the date (instead of "extract").
I haven't encountered the problem in #36 and haven't tested this patch when specifying modules.
Comment #38
gábor hojtsyIf there are bugs with the drush integration, please fix those in the 6.x-3.x version which is our reference version and then work from there to port it again to 7.x.
Comment #39
s_leu commentedBugs in the 7.x-2.x version may not exist in the 6.x-3.x version because the first patch for 7.x-2.x isn't actually a port, it's a rewrite. Not 100% sure though, thus 6.x-3.x should be tested. Unfortunately i don't have time at the moment.
Comment #40
pbuyle commentedUsing the unmodified potx.drush.inc file from the 6.x-3.x branch inside the 7.x-1.x branch, I did not observe the behavior reported in #36.
Is there any reason not to commit this file to the 7.x-1.x branch ?
Once done, this issue could be closed and Drush related issues could be handled like any other issues.
Comment #41
pbuyle commentedFor reference (or usage un Drush Make files), the attached patch add a copy of the potx.drush.inc from the 6.x-3.x branch and should apply on the 7.x-1.x branch.
Comment #42
pbuyle commentedComment #44
herom commentedPorted potx.drush.inc to the 7.x-2.x branch. This is a closer match to the 6.x version than previous patches, and doesn't contain the bugs described in the comments.
Comment #47
SebCorbin commentedPorted to 7.x-3.x as it has been branched directly from 6.x-3.x