Comments (16)
Hi @atimmer, the makepo
task that's still in development will only create a PO file if one doesn't already exist. I added a note that msgmerge
would be useful, but I'm not currently aware of any Node-based alternatives (nothing in grunt-wp-i18n currently depends on gettext).
I imagine progressively enhancing the existing functionality when the gettext utilities are available can't hurt and can be replaced if an alternative ever becomes available.
With that in mind, I can see this being useful in a couple of places:
- A new option in the
makepot
task would allow all the PO files to be updated any time the POT file is generated. - The
makepo
task currently only works for creating a new PO file for a single locale. It might be possible to update that task to runmsgmerge
on all existing PO files when it's called or the single locale file when it's specified.
We can probably go ahead with 2 for now, while keeping 1 in mind for the future. Does that sounds like it'd solve your use case and something you'd be interested in submitting a PR for?
from grunt-wp-i18n.
I made a pull request that is a very small task wrapper around msgmerge
.
We can solve both cases using this task. Do you think it is a good idea to have it in a separate task or should it somehow be a 'private' function?
from grunt-wp-i18n.
Nice work, @atimmer! I'm not too keen on exposing a new task, though, so I'm thinking the functionality could be wrapped up in a module in the /tasks/lib
directory and a new option can be added to the makepot
task to enable it (something like updatePoFiles: true
), but I'm open to suggestions.
from grunt-wp-i18n.
I updated the pull request with the suggestions. updatePoFiles
is a great idea, currently it is off by default. Tell me if you want it on by default. msgMerge is moved to /tasks/lib
.
When makepo is implemented it can make use of msgMerge.
If this is the correct direction I will add some documentation to the pull request.
from grunt-wp-i18n.
This looks great. Off by default is good since that option requires an external dependency.
When you add the docs, this section could use a few spaces to match the WP JS coding standards. Let me know when you get everything wrapped up and I'll do some testing and merge this.
Thanks a ton!
from grunt-wp-i18n.
The pull request should be done now. I've added some documentation and support for themes, because the PO files format is different for them.
from grunt-wp-i18n.
I left some comments on a couple of the commits for issues I noticed after pulling this down and giving it a quick run through. Once those are addressed, I think this should be good to go.
from grunt-wp-i18n.
They should all be fixed now, I actually got the backup files as well but my editor doesn't show them.
from grunt-wp-i18n.
Looks good! Once last thing, can you squash these commits? I'll merge it after that.
from grunt-wp-i18n.
Squashed.
from grunt-wp-i18n.
Merged. I'll run a few more tests and try to push out an update soon. Thanks again!
from grunt-wp-i18n.
I'm seeing the tests fail with this
Running "makepot:msg_merge_merging" (makepot) task
>> POT file saved to tmp/msg-merge/msg-merge.pot
>> msgmerge error:Error: Error: not found: msgmerge
>> msgmerge error:Error: Error: not found: msgmerge
Maybe I haven't got msgmerge available as a tool on this machine, but the tests should check for that and skip those with a suitable message.
Testing makepot_test.js..........F.F.
>> makepot - msg_merge_merging
>> Message: "Colors" string should exist
>> Error: undefined == true
>> at Object.exports.makepot.msg_merge_merging (test/makepot_test.js:173:8)
>> at Object.exports.makepot.setUp (test/makepot_test.js:28:3)
>> makepot - msg_merge_merging
>> Message: "Colors" string should exist
>> Error: undefined == true
>> at Object.exports.makepot.msg_merge_merging (test/makepot_test.js:174:8)
>> at Object.exports.makepot.setUp (test/makepot_test.js:28:3)
>> makepot - msg_merge_merging
>> Error: Expected 4 assertions, 2 ran
>> at processImmediate [as _immediateCallback] (timers.js:358:17)
>> makepot - msg_merge_merging
>> TypeError: Cannot read property 'comments' of undefined
>> at Object.exports.makepot.msg_merge_merging (test/makepot_test.js:176:47)
>> at Object.exports.makepot.setUp (test/makepot_test.js:28:3)
>> makepot - msg_merge_theme
>> Message: "Analog string should not exist
>> Error: false == true
>> at Object.exports.makepot.msg_merge_theme (test/makepot_test.js:205:8)
>> at Object.exports.makepot.setUp (test/makepot_test.js:28:3)
>> makepot - msg_merge_theme
>> Message: "Digital" string should exist
>> Error: undefined == true
>> at Object.exports.makepot.msg_merge_theme (test/makepot_test.js:206:8)
>> at Object.exports.makepot.setUp (test/makepot_test.js:28:3)
Warning: 6/59 assertions failed
(Also appears to be missing a double quote in one of the error message strings).
from grunt-wp-i18n.
I took a look into excluding those tests if msgmerge isn't available, but there doesn't appear to be a good way to detect whether or not an executable exists or to skip tests.
The one thing I can think of is to split the tests and add a flag to skip the ones that depend on msgmerge. Anyone have a better idea?
from grunt-wp-i18n.
To check if gettext is available I thought of two approaches:
- Add a
isGettextAvailable
function to the util file that callsgettext --version
and catches the error gracefully. - This: https://github.com/arturadib/shelljs and then call
which( 'msgmerge' )
to check for the command.
from grunt-wp-i18n.
Relevant (but old): caolan/nodeunit#12
from grunt-wp-i18n.
Very easy, just be smart ;)
You can use shelljs
for checking if msgmerge
is found in system PATH or not.
https://github.com/axisthemes/grunt-potomo/blob/master/tasks/potomo.js#L20-L23
The shelljs
module which()
is prepared to deal with command
in the system's PATH:
https://github.com/arturadib/shelljs/blob/master/src/which.js#L33-L82
As I said, just be smart ;)
from grunt-wp-i18n.
Related Issues (20)
- Ignore certain domain (e.g. via an options.dontUpdateDomains) HOT 12
- Warning: Cannot read property 'split' of undefined HOT 6
- Exclude page templates HOT 3
- "updateTimestamp: false" is not working properly HOT 3
- Exclude doesn't included in .pot file HOT 2
- Send modified files to build path only HOT 2
- Not Working on Windows ver > 8
- Good way to eliminate duplicates in pot file HOT 8
- Running "makepot" task keeps running forever HOT 4
- update node-wp-i18n to v1.0.5 HOT 1
- updateTimestamp: false not working HOT 8
- Detecting msgid stored in variable HOT 1
- Warning: Cannot read property 'pot-creation-date' of undefined Use --force to continue. HOT 1
- POT File by text domain HOT 2
- Switch to using `wp i18n make-pot` HOT 6
- Makepot supports for monorepo plugins HOT 1
- Addtextdomain throws error HOT 1
- Better output when makepot fails due to missing PHP cli
- Warnings when running on PHP 8 HOT 2
- Duplicate text domains added where text domain already exists HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grunt-wp-i18n.