cedaro / node-wp-i18n

Internationalize WordPress themes and plugins.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'wpi18n addtextdomain --exclude <folder>' not excluding

justintadlock opened this issue · comments

I attempted both of the following commands:

wpi18n addtextdomain --exclude vendor
wpi18n addtextdomain --exclude /vendor

In both cases, textdomains in the vendor folder were overwritten. I'm on Windows 10 with latest Node and NPM and attempting to get this to add the textdomain for a theme but not overwrite anything in the vendor folder.

I should note that makepot does in fact exclude vendor.

The exclude argument is specific to the makepot command, so it won't work with addtextdomain. A --glob-pattern option was recently added that should allow you to exclude directories, though.

Cool. I'll test that out and report back shortly. I didn't see it in the list of commands with wpi18n -h.

Yeah, it's relatively new and I haven't even used it myself, but the help text could probably use an update. Let me know if that doesn't work out for you.

It took me a while, but I managed to get it working for what I currently need with this:

wpi18n addtextdomain --glob-pattern=./!(vendor)/**/*.php

I'm not really up to speed on glob patterns. The example from the PR just gave me an error, so I've been trying out stuff.

Anyway, I'll close this for now unless you're interested in adding in an addtextdomain --exclude option. :)

I just ran a couple tests and it looks like this should work:

wpi18n addtextdomain --glob-pattern='!(vendor){*.php,**/*.php}'

The underlying library has a primer for glob patterns here.

That being said, I went ahead and tried adding support for an exclude option. If you want to give it a shot, you can install the development version like this:

npm install -g cedaro/node-wp-i18n#develop

Then you can run it with this command:

wpi18n addtextdomain --exclude=vendor

Awesome! I'm just putting up for the day because my laptop is about to die. I'll check it out over the weekend.

The --exclude option works great for me.

@justintadlock Thanks for testing it out. I've published this in version 1.2.0, so you can use that instead of the develop branch now.