|
| 1 | +--- |
| 2 | +title: Configuration |
| 3 | +description: All configuration options for loco-cli |
| 4 | +--- |
| 5 | + |
| 6 | +Options can be passed as CLI flags or defined in a config file. Config files are loaded via [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig): |
| 7 | + |
| 8 | +- `loco.config.js` (recommended) |
| 9 | +- `.locorc.yaml` |
| 10 | +- `.locorc.json` |
| 11 | +- `.locorc.js` |
| 12 | + |
| 13 | +## Example Config |
| 14 | + |
| 15 | +```js |
| 16 | +// loco.config.js |
| 17 | +/** @type {import('loco-cli/types').Config} */ |
| 18 | +module.exports = { |
| 19 | + accessKey: '<loco-full-access-key>', |
| 20 | + localesDir: 'src/app/i18n/locales', |
| 21 | + namespaces: false, |
| 22 | + push: { |
| 23 | + 'flag-new': 'provisional', |
| 24 | + 'tag-new': process.env.npm_package_version, |
| 25 | + 'delete-absent': false |
| 26 | + } |
| 27 | +}; |
| 28 | +``` |
| 29 | + |
| 30 | +## Global Options |
| 31 | + |
| 32 | +| Config key | CLI flag | Type | Description | |
| 33 | +|------------|----------|------|-------------| |
| 34 | +| `accessKey` | `-a`, `--access-key <key>` | `string` | The API key from your Loco project. Find it under **Developer Tools → API Keys → Full Access Key**. An Export key works for pull-only usage. | |
| 35 | +| `localesDir` | `-d`, `--locales-dir <path>` | `string` | Folder containing JSON translation files. Defaults to current directory. | |
| 36 | +| `namespaces` | `-N`, `--namespaces` | `boolean` | Organize translations into namespaces (default: `false`). When enabled, asset IDs are prefixed with `<namespace>:`. | |
| 37 | +| `maxFiles` | `-m`, `--max-files <number>` | `number` | Maximum files to display in diff output (default: `20`). | |
| 38 | +| `push` | — | `PushOptions` | Options for `loco-cli push`. See below. | |
| 39 | +| `pull` | — | `PullOptions` | Options for `loco-cli pull`. See below. | |
| 40 | + |
| 41 | +## Push Options |
| 42 | + |
| 43 | +Options passed to the [Loco import API](https://localise.biz/api/docs/import/import): |
| 44 | + |
| 45 | +| Option | Description | |
| 46 | +|--------|-------------| |
| 47 | +| `ignore-new` | New assets will NOT be added to the project | |
| 48 | +| `ignore-existing` | Existing assets will NOT be updated | |
| 49 | +| `tag-new` | Tag new assets with given tags (comma separated) | |
| 50 | +| `tag-all` | Tag ALL assets in the file (comma separated) | |
| 51 | +| `untag-all` | Remove tags from matched assets (comma separated) | |
| 52 | +| `tag-updated` | Tag assets modified by this import | |
| 53 | +| `untag-updated` | Remove tags from modified assets | |
| 54 | +| `tag-absent` | Tag assets NOT found in the imported file | |
| 55 | +| `untag-absent` | Remove tags from assets NOT in the file | |
| 56 | +| `delete-absent` | **Permanently delete** assets NOT in the file (use with caution) | |
| 57 | +| `flag-new` | Set flag on new non-empty translations | |
| 58 | + |
| 59 | +## Pull Options |
| 60 | + |
| 61 | +Options passed to the [Loco export API](https://localise.biz/api/docs/export/exportall): |
| 62 | + |
| 63 | +| Option | Description | |
| 64 | +|--------|-------------| |
| 65 | +| `filter` | Filter by tags. Match any with `*`, negate with `!` prefix | |
| 66 | +| `fallback` | Fallback locale for untranslated assets (e.g., `en` or `en_GB`) | |
| 67 | +| `order` | Export according to asset order | |
| 68 | +| `status` | Export by status/flag. Negate with `!` (e.g., `translated`, `!fuzzy`) | |
| 69 | +| `charset` | Preferred character encoding | |
| 70 | +| `breaks` | Force platform-specific line endings (default: Unix LF) | |
0 commit comments