npm package: @ilabdev/translate
Description: Gulp tasks for translating PHP files
Author: Innovation Lab
Latest version: 1.0.0

# `@ilabdev/translate`

> Gulp tasks for translating PHP files

## Installation & set up

Install `@ilabdev/translate`

```shell
npm install @ilabdev/translate --save-dev

-- OR --

yarn add @ilabdev/translate --dev
```

Include `@ilabdev/translate` in your `gulpfile.js`

**NOTE:** Make sure you pass `gulp` through to the package as shown below. The package sets up gulp tasks and will need it passed through to work.

```js
require( '@ilabdev/translate' )( gulp )
```

Add the content from `config.sample.js` to your `.gulpconfig.js` and adjust as appropriate

```js
module.exports = {
    // Other configs here...
    translate: {
        process: true,
        watch: true,
        logColor: 'black',
        areas: [
            {
                paths: {
                    src: './**/*.php',
                    watch: './**/*.php',
                    dest: './languages/PACKAGE.pot',
                },
                pipes: {
                    // Put any pipe overrides here
                    src: {
                        allowEmpty: true,
                    },
                    dest: {},
                },
            },
        ],
        pipes: {
            watch: {
                events: 'all',
            },
            checktextdomain: {
                /* eslint-disable camelcase */
                text_domain: 'PACKAGE',
                keywords: [
                    '__:1,2d',
                    '_e:1,2d',
                    '_x:1,2c,3d',
                    '_ex:1,2c,3d',
                    '_n:1,2,4d',
                    '_nx:1,2,4c,5d',
                    '_n_noop:1,2,3d',
                    '_nx_noop:1,2,3c,4d',
                    'esc_html__:1,2d',
                    'esc_html_e:1,2d',
                    'esc_html_x:1,2c,3d',
                    'esc_attr__:1,2d',
                    'esc_attr_e:1,2d',
                    'esc_attr_x:1,2c,3d',
                ],
                report_missing: true,
                report_success: false,
                report_variable_domain: true,
                correct_domain: true,
                create_report_file: false,
                force: false,
                /* eslint-enable camelcase */
            },
            pot: {
                domain: 'PACKAGE',
                package: 'Project Name',
                lastTranslator: 'PACKAGE AUTHOR <PACKAGE@EMAIL.COM>',
                headers: {
                    'Language-Team': 'PACKAGE AUTHOR <PACKAGE@EMAIL.COM>',
                },
            },
        },
    },
    // Other configs here...
}
```

Run `gulp translate` to run the translation task, `gulp translate:watch` to run the watch task, or add the task as a script and run that with `npm` or `yarn`

## Config

### `process`

Type: `boolean`

Whether to translate PHP files or not

### `watch`

Type: `boolean`

Whether to watch PHP files for changes or not

### `loggerColor`

Type: `string`

The logger color to use for any output text. See https://github.com/stgdp/fancy-logger#available-modifiers for colors that can be used

### `areas`

Type: `object[]`

The areas to be translated. Each area has it's own, isolated settings to allow for separate configs

### `areas[].paths`

Type: `object`

Path references for the translator

### `areas[].paths.src`

Type: `string[]|string`

The paths to translated. Passed through to `gulp.src`, items can be globs

### `areas[].paths.watch`

Type: `string[]|string`

The paths to watched. These are combined into a single array and passed through to `gulp.watch`

### `areas[].paths.dest`

Type: `string`

The destination file of the `.pot` output. Passed through to `gulp.dest`, items can be globs

### `areas[].pipes`

Type: `object`

Options to be passed through to the pipes.

### `areas[].pipes.src`

Type: `object`

Options to be passed through to the `gulp.src` pipe. See https://gulpjs.com/docs/en/api/src/ for more information

### `areas[].pipes.dest`

Type: `object`

Options to be passed through to the `gulp.dest` pipe. See https://gulpjs.com/docs/en/api/dest/ for more information

### `pipes`

Type: `object`

Options to be passed through to the pipes.

### `pipes.watch`

Type: `object`

Options to be passed through to the `gulp.watch` pipe. See https://gulpjs.com/docs/en/api/watch/ for more information

### `pipes.checktextdomain`

Type: `object`

Options to be passed through to `gulp-checktextdomain`. See https://www.npmjs.com/package/gulp-checktextdomain for more information

### `pipes.pot`

Type: `object`

Options to be passed through to `gulp-wp-pot`. See https://www.npmjs.com/package/gulp-wp-pot for more information