cedaro / grunt-wp-i18n

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

Fix project-id-version issues ... #21

Closed shivapoudel closed 10 years ago

shivapoudel commented 10 years ago

When developer have to generate more than single pot files then they have to make some changes. For ease, if we want to create seperate two pot for admin interface and frontend interface for specific plugin similar like WooCommerce then how could we modify the project-id-version ? Also please adapt this in potHeaders and make its documentation in readme soon?

makepot: {
    backend: {
        options: {
            cwd: 'i18n/languages',
            processPot: function( pot, options ) {
                pot.headers['project-id-version'] = '{name} {version} Admin Interface';
                return pot;
            },
            type: 'wp-plugin'
        }
    }
}
bradyvercher commented 10 years ago

Hi @shivapoudel, I'm not sure how common it is to generate separate POT files like that, but as for the project-id-version, hardcoding the name should be fine since that shouldn't change between builds. The version could be pulled from package.json if needed, although I see how some of that data could be useful in the callback.

shivapoudel commented 10 years ago

Solve like this:

        // Generate POT files.
        makepot: {
            options: {
                type: 'wp-plugin',
                domainPath: 'i18n/languages',
                potHeaders: {
                    'report-msgid-bugs-to': 'https://github.com/axisthemes/axis-framework/issues',
                    'language-team': 'LANGUAGE <EMAIL@ADDRESS>',
                    'plural-forms': 'nplurals=2; plural=n != 1;',
                    'language': 'en_US',
                    'x-poedit-sourcecharset': 'UTF-8'
                }
            },
            frontend: {
                options: {
                    potFilename: 'axisframework.pot',
                    exclude: [
                        'includes/config/.*',
                        'includes/admin/.*',
                        'apigen/.*'
                    ],
                    processPot: function ( pot ) {
                        pot.headers['project-id-version'] += ' Frontend';
                        return pot;
                    }
                }
            },
            admin: {
                options: {
                    potFilename: 'axisframework-admin.pot',
                    include: [
                        'includes/admin/.*',
                    ],
                    processPot: function ( pot ) {
                        pot.headers['project-id-version'] += ' Admin';
                        return pot;
                    }
                }
            }
        },