Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not parse twig files #5

Open
oleksandr-diudiun opened this issue Feb 7, 2013 · 80 comments
Open

Not parse twig files #5

oleksandr-diudiun opened this issue Feb 7, 2013 · 80 comments

Comments

@oleksandr-diudiun
Copy link

Poedit error message:

Невозможно выполнить программу: /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditTFylWe/17extracted.pot" --from-code=UTF-8  -k_ -kgettext -kgettext_noop -L PHP --files  
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-forms.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-header.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-image-uploader.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-item-meta.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-links-header.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-message.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-meta.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploaded-files.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploaded-images.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploader-file.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploader-image.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/frontend-links-header.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/frontend-meta.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/frontend.twig" 
"/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/tpl-tabs.twig"

How I install Extractor in terminal:
 2013-02-07 16 21 21
 2013-02-07 16 22 11

sh-3.2# php composer.phar install --dev
Loading composer repositories with package information
Installing dependencies
  - Installing symfony/translation (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing twig/twig (dev-master c6445fb)
    Cloning c6445fb5cd6823f7bd65108a717064957b6eafd5

  - Installing symfony/filesystem (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing symfony/routing (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing symfony/twig-bridge (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing twig/extensions (dev-master 5c2d515)
    Cloning 5c2d515d4624bdd588226d688173cf0399a4d8cf

  - Installing umpirsky/twig-gettext-extractor (1.1.2)
    Loading from cache

  - Installing symfony/options-resolver (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing symfony/locale (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing symfony/event-dispatcher (2.1.x-dev v2.1.7)
    Cloning v2.1.7

  - Installing symfony/form (2.1.x-dev v2.1.7)
    Cloning v2.1.7

Loading composer repositories with package information
Installing dev dependencies
Nothing to install or update
symfony/translation suggests installing symfony/config (2.1.*)
symfony/translation suggests installing symfony/yaml (2.1.*)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
symfony/routing suggests installing symfony/config (2.1.*)
symfony/routing suggests installing symfony/yaml (2.1.*)
symfony/twig-bridge suggests installing symfony/templating (2.1.*)
symfony/twig-bridge suggests installing symfony/yaml (2.1.*)
symfony/twig-bridge suggests installing symfony/security (2.1.*)
symfony/locale suggests installing ext-intl (>=5.3.3)
symfony/event-dispatcher suggests installing symfony/dependency-injection (2.1.*)
symfony/event-dispatcher suggests installing symfony/http-kernel (2.1.*)
symfony/form suggests installing symfony/validator (2.1.*)
symfony/form suggests installing symfony/http-foundation (2.1.*)
Writing lock file
Generating autoload files
sh-3.2# ls
.DS_Store   composer.json   composer.lock   composer.phar   vendor
@umpirsky
Copy link
Owner

umpirsky commented Feb 7, 2013

Hi, thanks for using Twig Gettext Extractor!

Can you please run command from "Poedit error message", and post the output.

@oleksandr-diudiun
Copy link
Author

 2013-02-07 18 21 42

@umpirsky
Copy link
Owner

umpirsky commented Feb 7, 2013

Please run that gettext command and paste text output instead of image screenshots, use markdown.

@oleksandr-diudiun
Copy link
Author

sh-3.2# /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditaOSeOc/17extracted.pot" --from-code=UTF-8  -k_ -kgettext -kgettext_noop -L PHP --files  "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-forms.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-header.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-image-uploader.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-item-meta.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-links-header.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-message.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-meta.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploaded-files.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploaded-images.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploader-file.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend-uploader-image.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/backend.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/frontend-links-header.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/frontend-meta.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/frontend.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/abstracts/tpl-tabs.twig"
xgettext: невозможно создать файл вывода "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditaOSeOc/17extracted.pot": No such file or directory
Fatal error: Uncaught exception 'RuntimeException' with message 'Gettext command "xgettext --sort-output --force-po -o /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditaOSeOc/17extracted.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d48 in /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php on line 79

@umpirsky
Copy link
Owner

umpirsky commented Feb 8, 2013

No, not that command, run command that is reported to fail in error message xgettext --sort-output --force-po ....

@oleksandr-diudiun
Copy link
Author

sh-3.2# xgettext --sort-output --force-po -o /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditaOSeOc/17extracted.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d4851d4ed/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/5113d48
xgettext: ошибка открытия файла "/tmp/cache/5113d48" для чтения: No such file or directory

@umpirsky
Copy link
Owner

umpirsky commented Feb 8, 2013

Command is cat, hehumm.

According to this message xgettext: невозможно создать файл вывода "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditaOSeOc/17extracted.pot": No such file or directory looks like this pot file is missing.

Is your Poedit configured to use this pot file? Do you have it?

You can try to run same command witout last cutted path.

@oleksandr-diudiun
Copy link
Author

Poedit work perfectly with PHP code and generate/read/write .pot and .po and .mo files and when He try also parse twig after php He answered error. The .../17extracted.pot file generate by your extractor and i have /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/ but have not poeditaOSeOc/17extracted.pot

@umpirsky
Copy link
Owner

umpirsky commented Feb 8, 2013

I would like you to show me the piece of code in Twig Gettext Extractor where 17extracted.pot is being generated.

It is not generated by Twig Gettext Extractor, but by Poedit.

Can you give me your parser command from Poedit preferences?

Also, try t run it on fewer twig templates, for example 2 or 3. Looks like command is too long and is cutted. Then paste output again.

@oleksandr-diudiun
Copy link
Author

Run with few templates:

sh-3.2# /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot" --from-code=UTF-8  -k_ -kgettext -kgettext_noop -L PHP --files  "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-default.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-edit.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-front-menu.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-menu.twig"
xgettext: невозможно создать файл вывода "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot": No such file or directory
Fatal error: Uncaught exception 'RuntimeException' with message 'Gettext command "xgettext --sort-output --force-po -o /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php" failed with error code 1 and output: ' in /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php:79
Stack trace:
#0 /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/umpirsky/twig-gettext-extractor/twig-gettext-extractor(58): Twig\Gettext\Extractor->extract()
#1 {main}
  thrown in /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/umpirsky/twig-gettext-extractor/Twig/Gettext/Extractor.php on line 79

@umpirsky
Copy link
Owner

OK, and when you run:

xgettext --sort-output --force-po -o /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php

?

@oleksandr-diudiun
Copy link
Author

In errors in my post i see that file ...IZ5x/0extracted.pot not created, than i try to change path to file and run again:

sh-3.2# /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/0extracted.pot" --from-code=UTF-8  -k_ -kgettext -kgettext_noop -L PHP --files  "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-default.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-edit.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-front-menu.twig" "/Users/noon-ehos/work/sources/vnmu.loc/views/profile/profile-menu.twig"
sh-3.2#

And i have no errors, and 0extracted.pot was created in /var/folders/ and i have next body of file:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR , YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-14 13:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

@oleksandr-diudiun
Copy link
Author

if I run your last command, it's look like this:

sh-3.2# xgettext --sort-output --force-po -o /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php
xgettext: невозможно создать файл вывода "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot": No such file or directory

@umpirsky
Copy link
Owner

Change /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot to pont to your .pot file and run again.

@oleksandr-diudiun
Copy link
Author

my Parser command:

/Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/bin/twig-gettext-extractor --sort-output --force-po -o %o %C %K -L PHP --files %F

@umpirsky
Copy link
Owner

From #5 (comment) change /var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poeditatIZ5x/0extracted.pot to pont to your .pot file and run again.

@oleksandr-diudiun
Copy link
Author

sh-3.2# xgettext --sort-output --force-po -o Users/noon-ehos/work/sources/vnmu.loc/languages/messages.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php
xgettext: невозможно создать файл вывода "Users/noon-ehos/work/sources/vnmu.loc/languages/messages.pot": No such file or directory

but this file alredy exist and have maybe 400 lines with phrases

@oleksandr-diudiun
Copy link
Author

Sorry, I was run it as local path without first "/"
So true resalt is:

sh-3.2# xgettext --sort-output --force-po -o /Users/noon-ehos/work/sources/vnmu.loc/languages/messages.pot --from-code=UTF-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php
sh-3.2# 

@oleksandr-diudiun
Copy link
Author

and now my pot file look like:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR , YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-02-14 13:27+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME \n"
"Language-Team: LANGUAGE \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

@oleksandr-diudiun
Copy link
Author

but old file was have much more data

@oleksandr-diudiun
Copy link
Author

I was try to see what I have in /tmp/cache/511cc30159f39/f0/9d/e8ec729d8f0c5a034863632073d1.php and it's standart twig=>php cache but without some _() or gettext() functions and without phrases, so i was try see other cache files and understand that it is the same file repited 5 times in command :(

@umpirsky
Copy link
Owner

I can find some time to debug this during the weekend. Can you create a test repo on github so we can debug?

@oleksandr-diudiun
Copy link
Author

Ok, i will create repo and post url here in few hours

@umpirsky
Copy link
Owner

Perfect, thanks!

@oleksandr-diudiun
Copy link
Author

https://github.com/noon-ehos/potest.loc I add you as collaborator.

@umpirsky
Copy link
Owner

👍

@umpirsky
Copy link
Owner

You missed composer.json, and extractor dependency in it :)

@oleksandr-diudiun
Copy link
Author

@umpirsky
Copy link
Owner

Please try this, it worked for me:

$ git clone [email protected]:noon-ehos/potest.loc.git (or pull)
$ cd potest.loc
$ composer install

Now open messages.po with Poedit, and update from sources, you should get Some TWIG text fetched.

@oleksandr-diudiun
Copy link
Author

OS X Mountain lion, Latest Poedit

  • Create new project
  • choose messages.po
  • run search:
    Невозможно выполнить программу: /Users/noon-ehos/work/sources/Twig-Gettext-Extractor/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/var/folders/vg/0_6ypnj11cs5hd0yxwd6hbyc0000gn/T/poedit9nrg0V/0extracted.pot" --from-code=utf-8  -k_ -kgettext -kgettext_noop -L PHP --files  "twig/test.twig"
    

@umpirsky
Copy link
Owner

Why it does not work now? :)

If you really gave it 777, it should look like:

drwxrwxrwx 2 root root  4096 Feb 15 14:18 /var/folder

@oleksandr-diudiun
Copy link
Author

Yes it look like: drwxrwxrwx 8 root wheel 272 Feb 14 20:02 folders

.....

For project
drwxrwxrwx 13 noon-ehos staff 442 Feb 15 15:12 .git
-rwxrwxrwx 1 noon-ehos staff 18 Feb 14 19:12 .gitignore
-rwxrwxrwx 1 noon-ehos staff 152 Feb 14 19:12 README.md
drwxrwxrwx 3 noon-ehos staff 102 Feb 15 11:57 bin
-rwxrwxrwx 1 noon-ehos staff 531 Feb 14 19:12 composer.json
-rwxrwxrwx 1 noon-ehos staff 23084 Feb 14 19:12 composer.lock
-rwxrwxrwx 1 noon-ehos staff 673891 Jan 24 19:10 composer.phar
-rwxrwxrwx 1 noon-ehos staff 484 Feb 15 15:05 messages.mo
-rwxrwxrwx 1 noon-ehos staff 594 Feb 15 15:05 messages.po
drwxrwxrwx 4 noon-ehos staff 136 Feb 15 12:35 twig
drwxrwxrwx 8 noon-ehos staff 272 Feb 14 19:15 vendor

@oleksandr-diudiun
Copy link
Author

But have same error

@umpirsky
Copy link
Owner

And 17extracted.pot file have all privs?

@oleksandr-diudiun
Copy link
Author

this file not created on run from Poedit

@umpirsky
Copy link
Owner

So it is created when you click to update from sources? Maybe it gives him wrong privileges.

Try to chmod it from vendor/bin/twig-gettext-extractor , it is in $_SERVER['argv'][1] or sth like that.

@oleksandr-diudiun
Copy link
Author

I test it another method. I change parder command %o to my project folder where I have all in 777 and POedit can't create file in this folder too :(

Невозможно выполнить программу: /Users/noon-ehos/work/sources/potest.loc/vendor/bin/twig-gettext-extractor --sort-output --force-po -o "/Users/noon-ehos/work/sources/potest.loc/meess.pot" --from-code=utf-8  -k_ -kgettext -kgettext_noop -L  PHP --files  "twig/test.twg"

@oleksandr-diudiun
Copy link
Author

but command from error message work from terminal without sudo. %( ?????

@umpirsky
Copy link
Owner

No idea, like your Poedit have some kind of sandbox and run extractor with limited privileges :P

Try to add sudo to command, just curious https://github.com/umpirsky/Twig-Gettext-Extractor/blob/master/Twig/Gettext/Extractor.php#L72

@oleksandr-diudiun
Copy link
Author

Poedit error:

sudo: no tty present and no askpass program specified

I think that poedit can't run correct twig-gettex-textractor througth PHP

@oleksandr-diudiun
Copy link
Author

I set exit(); in first lines your twig-gettex-textractor and error from poedit has no changes

@umpirsky
Copy link
Owner

If you want to debug it, log to files.

@oleksandr-diudiun
Copy link
Author

command "system" not working
call my func with print_r to file and exit(), it return result = 127

Extractor.php:

 public function extract()
    {
        $command = 'xgettext';
        $command .= ' '.join(' ', $this->parameters);
        $command .= ' '.join(' ', $this->templates);
        $error = 0;
        $output = system($command, $error);
fprint_xarray("log.txt",$error); // == 127
        if (0 !== $error) {
            throw new \RuntimeException(sprintf(
                'Gettext command "%s" failed with error code %s and output: %s',
                $command,
                $error,
                $output
            ));
        }
        $this->reset();
    }

@oleksandr-diudiun
Copy link
Author

safe_mode in php.ini and in phpinfo() set as Off

@oleksandr-diudiun
Copy link
Author

run:

...
        $error = 0;
        $output = system($command, $error);
fprint_xarray("log.txt",array($command,$output,$error));
...

Give me in file:

Array
(
    [0] => xgettext --sort-output --force-po -o /Users/noon-ehos/work/sources/potest.loc/meess.pot --from-code=utf-8 -k_ -kgettext -kgettext_noop -L PHP /tmp/cache/511e4af426cb7/9c/6d/d091dface6809a09565f5cf45742.php
    [1] => 
    [2] => 127
)

@oleksandr-diudiun
Copy link
Author

I finde that Extractor.php give /tmp/cache/511e4af426cb7/ dir name to system() function but atthe same time in File system was createt another tmp dir /tmp/cache/511e444864c8c/

@oleksandr-diudiun
Copy link
Author

no it was fail. names of dirs the same

@oleksandr-diudiun
Copy link
Author

all the same but function system() in extractor return false;

@oleksandr-diudiun
Copy link
Author

create some small test. I run code

show me:

string(0) "" 
int(127)

And

show me:

PHP 5.3.15 with Suhosin-Patch (cli) (built: Aug 24 2012 17:45:44) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies string(61) "Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies" 
int(0)

If i run xgettext --version in terminal without sudo I see good answer with current version
So what i can do for xgettext for run it correct from system() without sudo ? I expect it will be finish for me :)

@umpirsky
Copy link
Owner

Can you try with exec or passthru?

@oleksandr-diudiun
Copy link
Author

I try system, exec and passthru result: error - 127

@oleksandr-diudiun
Copy link
Author

I complete IT! 🎱 Problem for me was in system() function I need to set full path to xgettext tool now it look:

$command = '/opt/local/bin/xgettext';
        $command .= ' '.join(' ', $this->parameters);
        $command .= ' '.join(' ', $this->templates);
        $error = 0;
        $output = system($command, $error);

I try it before but I serch it with terminal tool

$ whereis xgettext
and have resalt
/usr/bin/gettext
When i use command
$ which xgettext
I have resalt
/opt/local/bin/xgettext

So I recommend to create some config var for path to xgettext in your tool
And also I want to help you to try create parser string format and standart config vars for xgettext path FOR Windows OS too.

@umpirsky
Copy link
Owner

On my system it is:

$ which xgettext
/usr/bin/xgettext

Maybe we can do which xgettext in Twig\Gettext\Extractor to detect location?

@oleksandr-diudiun
Copy link
Author

yes it's great idea but windows os? :)

@umpirsky
Copy link
Owner

Hehe, we can leave current behavior for windows or if which xgettext fails for any reason.

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')

If you can fix PR for this, it would be awesome.

@umpirsky
Copy link
Owner

PR, I mean pull request :)

@oleksandr-diudiun
Copy link
Author

ok, will try, it will be my first fork

@umpirsky
Copy link
Owner

No worries, I will help you, thanks!

@oleksandr-diudiun
Copy link
Author

Bad news, in my case system("which xgettext") not work too. And for example system("which php") work perfectly. In terminal both work perfect without sudo. Not understand what it can be...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants