|
| 1 | +# Scripts |
| 2 | + |
| 3 | +## POT Updater |
| 4 | + |
| 5 | +Standalone tool for checking and updating POT files in CakePHP plugins. |
| 6 | + |
| 7 | +### Installation |
| 8 | + |
| 9 | +Add to your plugin's `composer.json`: |
| 10 | + |
| 11 | +```json |
| 12 | +{ |
| 13 | + "require-dev": { |
| 14 | + "dereuromark/cakephp-translate": "^2.0" |
| 15 | + } |
| 16 | +} |
| 17 | +``` |
| 18 | + |
| 19 | +Then run: |
| 20 | +```bash |
| 21 | +composer update |
| 22 | +``` |
| 23 | + |
| 24 | +### Usage |
| 25 | + |
| 26 | +Run from your plugin's root directory: |
| 27 | + |
| 28 | +```bash |
| 29 | +# Check for differences (dry-run, default) |
| 30 | +php vendor/dereuromark/cakephp-translate/scripts/pot-updater.php |
| 31 | + |
| 32 | +# Update the POT file |
| 33 | +php vendor/dereuromark/cakephp-translate/scripts/pot-updater.php --update |
| 34 | + |
| 35 | +# CI mode: fail if POT is out of date |
| 36 | +php vendor/dereuromark/cakephp-translate/scripts/pot-updater.php --fail-on-diff |
| 37 | +``` |
| 38 | + |
| 39 | +### Composer Scripts |
| 40 | + |
| 41 | +Add to your plugin's `composer.json` for convenience: |
| 42 | + |
| 43 | +```json |
| 44 | +{ |
| 45 | + "scripts": { |
| 46 | + "pot-check": "php vendor/dereuromark/cakephp-translate/scripts/pot-updater.php --fail-on-diff", |
| 47 | + "pot-update": "php vendor/dereuromark/cakephp-translate/scripts/pot-updater.php --update" |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +Then use: |
| 53 | +```bash |
| 54 | +composer pot-check # Check if POT is up to date |
| 55 | +composer pot-update # Regenerate POT file |
| 56 | +``` |
| 57 | + |
| 58 | +### Options |
| 59 | + |
| 60 | +| Option | Description | |
| 61 | +|--------|-------------| |
| 62 | +| `--dry-run` | Compare and report differences without writing (default) | |
| 63 | +| `--update` | Actually update the POT file(s) | |
| 64 | +| `--verbose`, `-v` | Show detailed output including all strings | |
| 65 | +| `--quiet`, `-q` | Only output errors, suitable for CI | |
| 66 | +| `--path=<path>` | Custom paths to scan, comma-separated (default: `src,templates`) | |
| 67 | +| `--output=<path>` | Custom output path (default: `resources/locales`) | |
| 68 | +| `--domain=<name>` | Expected domain name (default: auto-detect from plugin name) | |
| 69 | +| `--fail-on-diff` | Exit with code 1 if differences found (for CI) | |
| 70 | +| `--ignore-references` | Ignore comment/reference differences | |
| 71 | +| `--help`, `-h` | Show help message | |
| 72 | + |
| 73 | +### Exit Codes |
| 74 | + |
| 75 | +| Code | Description | |
| 76 | +|------|-------------| |
| 77 | +| 0 | Success (POT file is up to date or was updated successfully) | |
| 78 | +| 1 | Differences found (when using `--fail-on-diff`) | |
| 79 | +| 2 | Error (could not read/write files, invalid options) | |
| 80 | + |
| 81 | +### CI Integration |
| 82 | + |
| 83 | +#### GitHub Actions |
| 84 | + |
| 85 | +```yaml |
| 86 | +- name: Check POT file is up to date |
| 87 | + run: composer pot-check |
| 88 | +``` |
| 89 | +
|
| 90 | +#### GitLab CI |
| 91 | +
|
| 92 | +```yaml |
| 93 | +pot-check: |
| 94 | + script: |
| 95 | + - composer pot-check |
| 96 | +``` |
0 commit comments