Closed fi5u closed 10 years ago
Sorry @fi5u - have you tried running grunt pot --verbose
- this will spew out a lot of information, including the files that have been parsed. (I know you mention that it works with watch, but there doesn't appear to be anything else that could be wrong).
grunt pot --verbose
returns the following:
Running tasks: pot
Running "pot" task
Running "pot:files" (pot) task
Verifying property pot.files exists in config...OK
Files: app/TestSite/404.php -> app/TestSite/404.php
Files: app/TestSite/archive.php -> app/TestSite/archive.php
Files: app/TestSite/comments.php -> app/TestSite/comments.php
Files: app/TestSite/content-featured-post.php -> app/TestSite/content-featured-post.php
Files: app/TestSite/content-page.php -> app/TestSite/content-page.php
Files: app/TestSite/content-single.php -> app/TestSite/content-single.php
Files: app/TestSite/content.php -> app/TestSite/content.php
Files: app/TestSite/footer.php -> app/TestSite/footer.php
Files: app/TestSite/functions.php -> app/TestSite/functions.php
Files: app/TestSite/header.php -> app/TestSite/header.php
Files: app/TestSite/image.php -> app/TestSite/image.php
Files: app/TestSite/inc/custom-header.php -> app/TestSite/inc/custom-header.php
Files: app/TestSite/inc/customizer.php -> app/TestSite/inc/customizer.php
Files: app/TestSite/inc/customizer_classes/wp_customizer_textarea.php -> app/TestSite/inc/customizer_classes/wp_customizer_textarea.php
Files: app/TestSite/inc/extras.php -> app/TestSite/inc/extras.php
Files: app/TestSite/inc/jetpack.php -> app/TestSite/inc/jetpack.php
Files: app/TestSite/inc/options.php -> app/TestSite/inc/options.php
Files: app/TestSite/inc/template-tags.php -> app/TestSite/inc/template-tags.php
Files: app/TestSite/inc/widgets/widget-hello-world.php -> app/TestSite/inc/widgets/widget-hello-world.php
Files: app/TestSite/inc/widgets/widget-latest-cats.php -> app/TestSite/inc/widgets/widget-latest-cats.php
Files: app/TestSite/inc/wpcom.php -> app/TestSite/inc/wpcom.php
Files: app/TestSite/index.php -> app/TestSite/index.php
Files: app/TestSite/no-results.php -> app/TestSite/no-results.php
Files: app/TestSite/page.php -> app/TestSite/page.php
Files: app/TestSite/search.php -> app/TestSite/search.php
Files: app/TestSite/searchform.php -> app/TestSite/searchform.php
Files: app/TestSite/sidebar.php -> app/TestSite/sidebar.php
Files: app/TestSite/single.php -> app/TestSite/single.php
Reading package.json...OK
Parsing package.json...OK
Options: dest="dev/wp-content/themes/TestSite/languages/", overwrite, keywords=["__","_e"], language=false, encoding=false, text_domain="test_site", package_version=undefined, package_name="test-site", msgid_bugs_address=false, omit_header=false, copyright_holder=false, comment_tag="/// TRANSLATORS:"
Pot options: dest="dev/wp-content/themes/TestSite/languages/", overwrite, keywords=["__","_e"], language=false, encoding=false, text_domain="test_site", package_version=undefined, package_name="test-site", msgid_bugs_address=false, omit_header=false, copyright_holder=false, comment_tag="/// TRANSLATORS:"
Destination: dev/wp-content/themes/TestSite/languages/test_site.pot
Executing: xgettext --default-domain=test_site -o dev/wp-content/themes/TestSite/languages/test_site.pot --keyword=__ --keyword=_e --package-name=test-site --add-comments='/// TRANSLATORS:' app/TestSite/404.php app/TestSite/archive.php app/TestSite/comments.php app/TestSite/content-featured-post.php app/TestSite/content-page.php app/TestSite/content-single.php app/TestSite/content.php app/TestSite/footer.php app/TestSite/functions.php app/TestSite/header.php app/TestSite/image.php app/TestSite/inc/custom-header.php app/TestSite/inc/customizer.php app/TestSite/inc/customizer_classes/wp_customizer_textarea.php app/TestSite/inc/extras.php app/TestSite/inc/jetpack.php app/TestSite/inc/options.php app/TestSite/inc/template-tags.php app/TestSite/inc/widgets/widget-hello-world.php app/TestSite/inc/widgets/widget-latest-cats.php app/TestSite/inc/wpcom.php app/TestSite/index.php app/TestSite/no-results.php app/TestSite/page.php app/TestSite/search.php app/TestSite/searchform.php app/TestSite/sidebar.php app/TestSite/single.php
Done, without errors.
So it seems to be identifying the correct files but still produces an empty pot file.
Well the main thing is that I haven't made any obvious mistakes in the settings that you can see. I'll investigate further.
Thanks for your help
I'll look into this. I assume the above string you wanted translate is in the 404.php file?
On a side note, I think you want the comment tag to be / TRANSLATORS:
. xgettext
says:
Place comment blocks starting with tag and preceding keyword lines in the output file...
So with your current set up it'll be looking for comments starting with /// TRANSLATORS:
e.g.
///// TRANSLATORS: ...
(which may be intended, but thought I'd mention it just in case :) - the docs on the readme aren't that explicit.)
Just thought are you using OSX...? The plug-in requires xgettext
which I don't think is installed by default...? (I think brew install gettext
does it...(?), but I don't use macs, so I can't check I'm afraid...)
I am using a Mac. I did brew install gettext
but it is already installed - gettext-0.18.3.2
.
Yes one of the strings to be translated is in 404.php. Thanks for mentioning about the comment tag, I did have it incorrect, I've now fixed that.
The same here on a Mac. Got an empty pot file. brew install gettext
did not work because command not found
. I´m lost.
Running "pot" task
Running "pot:files" (pot) task
Verifying property pot.files exists in config...OK
Files: fields/acf-table/acf-table.php -> fields/acf-table/acf-table.php
Reading package.json...OK
Parsing package.json...OK
Options: dest="fields/acf-table/lang-2/", overwrite, keywords=["gettext","__"], language=false, encoding=false, text_domain="acf-table", package_version="1", package_name="ACF Table Field", msgid_bugs_address=false, omit_header=false, copyright_holder=false, comment_tag="/", from_code="utf-8"
Pot options: dest="fields/acf-table/lang-2/", overwrite, keywords=["gettext","__"], language=false, encoding=false, text_domain="acf-table", package_version="1", package_name="ACF Table Field", msgid_bugs_address=false, omit_header=false, copyright_holder=false, comment_tag="/", from_code="utf-8"
Destination: fields/acf-table/lang-2/acf-table.pot
Executing: xgettext --default-domain=acf-table -o fields/acf-table/lang-2/acf-table.pot --keyword=gettext --keyword=__ --package-version=1 --package-name=ACF Table Field --add-comments='/' fields/acf-table/acf-table.php
Done, without errors.
Definitely a mac issues. 3 cases of this reported, all with macs. I've released an update which should, at least, display error messages from executing the xgettext
command. Probably along the lines of 'command not found'.
@johannheyne Regarding installing xgettext
on macs, I have no idea I'm afraid. Never touched a mac :).
Thanks,
I installed the package manager http://brew.sh/ on my mac, then installed "gettext" via terminal brew install gettext
, reinstalled "grunt-pot" in my project and there is your error message after grunt pot
…
Warning: Command failed: /bin/sh: xgettext: command not found
Use --force to continue.
The "gettext" is located /usr/local/Cellar/gettext/0.18.3.2/
I found a hint to do that: brew link gettext
, but it threw me even on brew link --force gettext
that message:
Linking /usr/local/Cellar/gettext/0.18.3.2... Warning: Could not link gettext. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/gettext/0.18.3.2/share/locale/zh_TW/LC_MESSAGES/gettext-tools.mo
/usr/local/share/locale/zh_TW/LC_MESSAGES is not writable. You should change its permissions.
Use these two lines in Terminal to get gettext installed and linked:
brew install gettext
brew link --force gettext
Then try something like this in your Gruntfile.js:
pot:{
options: {
text_domain: 'your-text-domain',
package_name: 'your-thing',
dest: 'your-build-directory',
keywords: [
'__',
'_e',
'_x',
'_n',
'_ex',
'_nx',
'esc_attr__',
'esc_attr_e',
'esc_attr_x',
'esc_html__',
'esc_html_e',
'esc_html_x',
'_nx_noop'
]
},
files: {
src: SOURCE_DIR + '**/*.php' ,
expand: true
}
},
Where SOURCE_DIR
is the directory you want this grunt process to scan.
Thank you @johnjamesjacoby brew link --force gettext
worked. It is now generating the pot file correctly!
Thanks @johnjamesjacoby :). I'll add a remark about this to the readme.
I was dealing with the same problem, brew install gettext && brew link --force gettext
fixed it for me. Thanks all :+1:.
@johnjamesjacoby ++ have a cookie!!
@johnjamesjacoby Thanks homie!
It would be really nice to be able to specify the location of the xgettext
command so the you don't have to have it in the path. is this possible?
I am using grunt-pot to help with WordPress development. However I cannot seem to get a pot file created with any content in, it always produces an empty pot file.
My grunt task looks like this:
I know the
files
>src
property is fine as the same one works for the watch task. Here is an example of what I want extracting into the pot file:Have I got an option set wrong? Many thanks
I'm using
grunt-pot
0.1.1