cedaro / grunt-wp-i18n

Internationalize WordPress themes and plugins with Grunt.
MIT License
160 stars 25 forks source link

Reduce dependencies: explore node gettext alternatives #2

Closed tollmanz closed 10 years ago

tollmanz commented 10 years ago

Installing gettext on your computer can be a real pain. It increases the barrier to entry for using this package. In fact, I've avoided installing gettext on OS X and opted to install in a VM instead.

I understand the major difficulties with this change. It would likely require forking the PHP based tools. I think it is worth exploring node based gettext alternatives. The usability of this package would be exponentially improved.

Here's what I've found so far:

I know nothing about the internals of the WP i18n tools, so this suggestion might be absolutely absurd. It is at least worth exploration.

bradyvercher commented 10 years ago

For the sake of plugins and themes, it appears that the msguniq utility is the only dependency. It removes duplicate messages from POT files, which are invalid input for some other utilities. This looks like it typically only happens for some of the headers that WordPress appends after extracting gettexted strings.

The POT file will still be generated if msguniq isn't available, but a notice will be displayed and any duplicate strings will still exist.

I've searched for a node-based implementation of msguniq, but didn't have much luck. It might be as simple using a node parser to load the pot file, weed out the duplicates and re-save the file.

The other option is to bundle the msguniq binary with this package, but I'm not sure what the ramifications of that would be at the moment.

bradyvercher commented 10 years ago

This should be taken care of in 1fe234a888. Basic testing showed duplicates were removed by simply parsing the POT file with a node gettext parser, then recompiling and saving the file.

I'll go ahead and close this out and push an update.

Thanks for the feedback @tollmanz. I hadn't considered the possibility of removing these dependencies beforehand, but like you said, it should exponentially improve the usability.

tollmanz commented 10 years ago

Dude...dude! This is amazing! I really thought that this was a stretch goal and you pull it off in less than 24 hours. Amazing!

I'm going to put this task through the paces later this week. Thanks for the great work.