cedaro / grunt-wp-i18n

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

Add includes option #24

Closed claudiosanches closed 10 years ago

claudiosanches commented 10 years ago

I'll be very grateful if you add more this parameter :)

bradyvercher commented 10 years ago

Hey @claudiosmweb, nice work on putting this together! I'll spend a little time trying it out and see if I can get it merged soon. Thanks!

Hey @shivapoudel, is this what you had in mind for #20?

claudiosanches commented 10 years ago

I'll be grateful if you could give merge. I plan to use it in WooCommerce, there have two .pot files, one for the frontend and one for the admin. And so it is difficult to use only the exclude.

Usage example:

makepot: {
    options: {
        type: 'wp-plugin',
        domainPath: 'i18n/languages'
    },
    frontend: {
        options: {
            potFilename: 'woocommerce.pot',
            exclude: [
                'includes/admin/.*',
                'apigen/.*'
            ],
            processPot: function( pot, options ) {
                pot.headers['project-id-version'] += ' Frontend';
                return pot;
            }
        }
    },
    admin: {
        options: {
            potFilename: 'woocommerce-admin.pot',
            include: [
                'includes/admin/.*'
            ],
            processPot: function( pot, options ) {
                pot.headers['project-id-version'] += ' Admin';
                return pot;
            }
        }
    }
}
bradyvercher commented 10 years ago

For that second target, have you tried excluding everything except the includes/admins directory? I haven't test this, but maybe something like this might work:

makepot: {
    options: {
        type: 'wp-plugin',
        domainPath: 'i18n/languages'
    },
    admin: {
        options: {
            potFilename: 'woocommerce-admin.pot',
            exclude: [
                '^(?!includes\/admin).*'
            ],
            processPot: function( pot, options ) {
                pot.headers['project-id-version'] += ' Admin';
                return pot;
            }
        }
    }
}
claudiosanches commented 10 years ago

Had not thought about it yet, I'll do a test later. But anyway, it would be interesting to have the includes parameter, since it is already part of xgettext().

claudiosanches commented 10 years ago

Cool! Thanks :)

bradyvercher commented 10 years ago

All thanks to you for the clean PR!