Open Saeven opened 10 years ago
Looks like there might be a bug in Poedit, so I have just another quick question for you. Which version of poedit have you successfully used with your script?
@Saeven Hehum...strange. I used it with 1.5.4-1.
Sorry to be daft, I'm partway trying to ascertain that I'm not crazy. Can you tell me what you have in your catalog preferences in the sources path section?
Also, what OS were you using 1.5.4-1 with?
I suggest to test with simplest data possible, one simple string.
I'm using Ubuntu 13.04.
Sorry to be a pain, but could you share a sample catalog config in sources path?
Unfortunately, I have no. But you can try with one string catalog.
Same issue here - I'm on Mac OS X
@arekkas Can you debug it?
it seems like poedit is telling xgettext to use a file that is inside a directory, poedit has not created yet. Which is weird, because the other parsers work.
The problem is, I can't really see why the command fails in poedit, only when executing it directly from cmd I see the error messages. However, when I modify the -o
parameter to an existing directory, the script is working fine
You can go into Twig-Gettext-Extractor
code and log information you need to see if files exist at that moment and all data you are inetrested in, right @arekkas? For example in https://github.com/umpirsky/Twig-Gettext-Extractor/blob/master/Twig/Gettext/Extractor.php#L70-L88
True, I'll have a closer look tomorrow
I had the same, or similar issues, as described here (and in other issues here). I'm on OSX. After picking Twig-Gettext-Extractor apart and rebuilding it again I found out that I only had to do three things (2 of them not described in the readme.md file).
./twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --files %F
I don't know if putenv('PATH='.getenv('PATH').':/opt/local/bin');
It seemed that PHP didnt find "gettext" because PHP wasn't allowed to look in /opt/local/bin. That caused all other issues I had basically. But it was very hard to debug.
Ping @umpirsky FYI. :)
It would be nice though if the twig-gettext-extractor could run as a service in a symfony/console command instead though. I tried to do that but I have yet to solve how that could be done. Or maybe if you could create a twig-gettext-extractor file that included the vendor/bin/twig-gettext-extractor file and only had to contain your custom extensions. This way makes it a bit less easy to keep up to date if/when Twig-Gettext-Extractor updates. But, well. It works now at least... I think. :)
@feedmeastraycat Thanks for sharing this man!
I didn't understand point 2. Did you copy extractor to poedits dir?
I would like to keep this decoupled from Symfony. People use it with other frameworks too. But I would like to see people integrating it with frameworks too.
@umpirsky No. My .pot file is located in /src/locale/ inside the project so I put base path to "../../" in Catalog > Properties > Sources path within Poedit. Then I have added "./src/views" in "Paths". And then I have "./twig-gettext-extractor" when I setup the twig parser. It seems that Poedit (1.6.5) understands that "./twig-gettext-extractor" is within the base path.
I had to copy twig-gettext-extractor from /vendor/bin/ because I needed to add some more extensions.
Here is a screenshot of my parser setup: https://www.dropbox.com/s/jc0svmt4wxmgepm/Screenshot%202014-05-21%2011.08.39.png
Here is a screenshot of my pot-file catalog properties: https://www.dropbox.com/s/fuwcury2w4az86q/Screenshot%202014-05-21%2011.09.53.png
Im still unsure if the example of <project>/vendor/bin/twig-gettext-extractor/ ...
is meant to be taken literarily. Or if I should replace <project>
with the full path to where my project is. But that seemed like a bad solution because that would make the twig parser project specific. But either way. Replacing <project>/
with ./
did the trick anyway. :)
The only problem I have now is that I want to use the {% trans %}
tag the way Symfony sets it up so I can use, for example {% trans with {'%name%':'David'} %}Hello %name%!{% endtrans %}
... But I havent figured that out yet. If it even can be done. :)
I understand that you wanna keep it decoupled from Symfony though. Makes sense. I will probably revisit that again and see if I can put it into the console.
You should replace
But I agree, it is not handy for project switching.
Thanks for the effort, really appreciate it.
@umpirsky Ok. Thanks. :) I wasn't sure from the readme if it was a placeholder or some poedit var. :D But cool. Now I know. But I'll keep ./
because I like to keep it not project specific. I know that Im gonna forget about that if else, and Im gonna spend weeks trying to figure out why it doesn't use my twig-gettext-extractor on my next project! ;)
I finally got it working, you need to execute POEdit (on Mac) like this: WXTRACE=poedit,poedit.tmp,poedit.execute /Applications/Poedit.app/Contents/MacOS/Poedit --verbose --keep-temp-files
Source: http://circlical.com/blog/2013/11/5/localizing-your-twig-using-zend-framework-2-applications
Works like a charm now, even with ZF2 :)
@arekkas Thanks for sharing. If this works on Mac I will accept PR with MacOS section instruction.
I'm on OSX Yosemite and the issue of missing folder under "/var" still continue. There are many OSX users that have same problem? Thank so much!
@barmarko27 Have you tried https://github.com/umpirsky/Twig-Gettext-Extractor/issues/12#issuecomment-44317644?
@umpirsky Yes, but don't work! It seems that Poedit can't delete the temp file.
Poedit parser configuration:
Poedit Command Line Execution:
Poedit Error:
Thanks for your support!
@arekkas Any idea why it does not work for @barmarko27? Thanks.
With the latest POedit version, you don't need WXTRACE=poedit,poedit.tmp,poedit.execute /Applications/Poedit.app/Contents/MacOS/Poedit --verbose --keep-temp-files
any more. Just start PoEdit regularly.
You'll also need to make sure that the path to twig-gettext-extractor
is correct by running it in the console.
@arekkas Yes the path to twig-gettext-extractor is correct. It seems that Poedit can't delete temporary folder after execution of Twig Parser. Thanks for helping me!
Is it a permission problem?
@barmarko27 did you start POEdit without --keep-temp-files
?
Platform: MacOS Yosemite 10.10.4 (14E46) Poeditor: 1.8.3 (3998) with xgettext 0.19.4.
When I starting Poeditor without parameters and trying to update translation from source, poeditor throws described error. With --keep-temp-files or with WXTRACE=poedit,poedit.tmp,poedit.execute exception is different:
Can't remove directory '/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditQ3Mdg2' (error 66: Directory not empty) Can't run application: PATH_TO_PROJECT/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditQ3Mdg2/14extracted.pot" --from-code=UTF-8 -ktranslate -L PHP --files "Application/view/application/index/index.twig"
Any idea?
Can't run application: PATH_TO_PROJECT/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditQ3Mdg2/14extracted.pot" --from-code=UTF-8 -ktranslate -L PHP --files "Application/view/application/index/index.twig"
Doesn't look like a real path to me ;)
Yes, real path has sensitive client data in names. But trust me - path is correct.
I see :) Does verbose give useful info?
In trace everything looks fine... Trace data before exception:
Trace: (poedit.tmp) new temp file /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW/14extracted.pot Trace: (poedit.execute) /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin//Users/urfin/Public/www/xxxx/xxxx/vendor/bin/twig-gettext-extractor doesn't exist, falling back to /Users/urfin/Public/www/xxxx/xxxx/vendor/bin/twig-gettext-extractor Trace: (poedit.execute) executing: /Users/urfin/Public/www/xxxx/xxxx/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW/14extracted.pot" --from-code=UTF-8 -ktranslate -L PHP --files "Application/view/application/index/index.twig" Trace: (poedit.tmp) keeping temp files in /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW Trace: (poedit.tmp) removing temp dir /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW
Just checked content of /var/folders/7f/hv40gb8x4cgg0v7wsbkm4djr0000gn/T/poeditmG51sW/ directory and 14extracted.pot not exists in there.
same problem here. start with --keep-temp-files ends in error 66# without --keep-temp-files ends in
Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/0extracted.pot Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/1extracted.pot Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/2extracted.pot Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/3extracted.pot Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/4extracted.pot Trace: (poedit.tmp) removing temp file /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08/5merged.pot Trace: (poedit.tmp) removing temp dir /var/folders/cz/3_w92y755tg8ksbss737427m0000gn/T/poeditwRmF08
Having the same problem:
Trace: (poedit.tmp) new temp file /var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ/0extracted.pot
Trace: (poedit.execute) /Applications/Poedit.app/Contents/PlugIns/GettextTools.bundle/Contents/MacOS/bin//Users/jzahner/Sites/joshmartin-website/vendor/bin/twig-gettext-extractor doesn't exist, falling back to /Users/jzahner/Sites/joshmartin-website/vendor/bin/twig-gettext-extractor
Trace: (poedit.execute) executing: /Users/jzahner/Sites/joshmartin-website/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ/0extracted.pot" --from-code=UTF-8 -L PHP --files "_angebot.twig" "_index.twig" "_kontakt.twig" "_team.twig" "_technologie.twig" "_werte.twig" "baselayout.twig"
Trace: (poedit.tmp) keeping temp files in /var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ
Trace: (poedit.tmp) removing temp dir /var/folders/nw/qt8p5kc174dfrw4r5pf3c67h0000gn/T/poeditZoZrEQ
Any Updates on this?
@jeremyzahner MacOS?
Yes! Sorry for leaving out that detail ^^
@jeremyzahner The problem is that I am a Linux user myself and project is tested on OSX by other users. Have you tried @arekkas suggestion from https://github.com/umpirsky/Twig-Gettext-Extractor/issues/12#issuecomment-44317644 ?
I can confirm this issue with recent POEdit versions. It works neither with --keep-temp-files
nor without. My best guess is to rollback your POEdit version.
Thanks for the update @arekkas. Let's try to ping Mr. @vslavik the author of Poedit, maybe he can give us some inside information about Poedit and how it handles files.
Let's try to ping Mr. @vslavik the author of Poedit, maybe he can give us some inside information about Poedit and how it handles files.
Sorry, it’s not really clear what you’re asking about — this issue is a bit of a mess to read through and I can’t quite make sense of all it. If you have a reproducible test case (one that doesn’t take half an eternity to setup), by all means, send it to me to have a look.
Without that, just a few assorted observations:
xgettext
command failing is bogus: of course it fails if you didn’t create the output directory (as Poedit would before invoking the command).--keep-temp-files
doesn’t make sense to me — that’s for debugging only!--keep-temp-files
(due to a minor bug where Poedit would still try to delete the dir despite the flag — I’ll fix that right away).*extracted.pot
file is not created and not kept with --keep-temp-files
(this is the only valid use for it: debugging if some files were created or not), then the only explanation is that the extractor tool that was supposed to create it didn't. Notice how the builtin extractors use the --force-po
to always create an output file, even if empty. If twig-gettext-extractor
doesn’t create an empty-but-valid POT file (i.e. with header, but no other msgids) when it doesn’t encounter any translatable strings, that would certainly cause this.twig-gettext-extractor
somewhere in PATH to use with all your projects), but I assume I must be missing something, and would welcome education (probably at help@poedit.net as it would be offtopic here).(BTW, I’m reworking extractors completely for the next major version (don’t worry, there will be “legacy” compatibility) and am soliciting any extractors-related feedback from, you know, real users of custom extractors — feel free to ping me at the above email address).
The errors about failing to delete the temp directory are caused by the use of --keep-temp-files (due to a minor bug where Poedit would still try to delete the dir despite the flag — I’ll fix that right away).
This will fix our issue 100%. It would be great if you could implement that!
This will fix our issue 100%. It would be great if you could implement that!
I feel like I might have not been as clear as I thought I was, so let me repeat myself in the interest of being absolutely clear:
DO NOT EVER USE --keep-temp-files
!
It doesn’t solve anything and is not meant to be used by end users! If it does seem to help you with something, please show me a reproducible test case of what it solves, using the latest Poedit version, and I’ll fix that, because that would uncover some serious issue — but to be frank, I simply don’t see how could anything of the sorts be possible.
Well I believe that the issue is as follows:
twig-gettext-extractor converts .twig (no native POEdit/xgettext support) files to .php files. These get stored in a temp dir and then iterated by xgettext. Somewhere inbetween, these files get deleted which is why xgettext is saying that they don't exist. This issue was "resolved" by telling POEdit to keep the files.
That's at least what I think is happening.
I see two problems with that theory:
twig-gettext-extractor
returns. There’s no way for it to delete files from under the extractor’s hands, even if they were located in Poedit’s temp directory.I’m more and more confused by the minute :-/
I'm sorry but I'm not sure if I can help you further. I ran into this issue some years ago and found the --keep-temp-files
fix in some blog. It worked back then but at some point I upgraded POEdit and it stopped working. It has not been working ever since. I also think that this issue is Mac only. Maybe Mac manages its temp directory in a different way than Linux. No idea.
Thanks for your response and willing to help @vslavik, I really appreciate it.
One thing is sure. I am 100% sure cache directories of Twig and Poedit are not shared. No doubt about that.
I never encouraged people to use --keep-temp-files
it was never in readme. I see they use it for debug purposes.
I agree this issue is too verbose and hard to read, so for the sake of sanity let's just wait for some Mac user to come up with proper and easy to reproduce test case.
Now we have @vslavik who is willing to take a look and I am very thankful. :+1:
One thing is sure. I am 100% sure cache directories of Twig and Poedit are not shared.
Still a mystery, then. Let’s wait for more details as you say, then.
I never encouraged people to use --keep-temp-files
Of course! I just wanted to clarify this for readers of this issue.
Any of you developers using this on OSX? I'm running into an issue where the call to your library:
Fails with this error message:
So attempting to run that command directly leads to:
All PHP these PHP scripts are owned by Me:admin on my filesystem. Seen this before?