> ## Documentation Index
> Fetch the complete documentation index at: https://hyperlocalise.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Translate PHP localization files with Hyperlocalise

> Translate static PHP locale arrays used by Laravel and other applications.

PHP locale files hold application messages in PHP array structures. Hyperlocalise supports the catalog syntax described below; use it for message resources rather than executable application logic.

Supported extensions: `.php`.

## Source file

Save this example as `locales/en-US/messages.php`.

```php theme={null}
<?php
return [
    'home' => [
        'title' => 'Welcome',
    ],
];
```

## Configure your files

Use this `i18n.yml` for the example, or add its file mapping to your existing bucket.
See [path templates](/cli/configuration/path-templates) for other layouts.

```yaml theme={null}
locales:
    source: en-US
    targets:
        - es-ES

buckets:
    messages:
        files:
            - from: locales/en-US/messages.php
              to: locales/{{target}}/messages.php

llm:
    profiles:
        default:
            provider: openai
            model: gpt-5.2
```

## Translate

[Install the CLI](/cli/getting-started/install) and set `OPENAI_API_KEY` in your
project's `.env.local` or shell. You can also configure another
[AI provider](/cli/providers/overview).

```bash theme={null}
hyperlocalise run --dry-run
hyperlocalise run
```

The dry run previews the work. The second command writes translations to the
configured target path and updates the lockfile.

## Behavior and limitations

* Files must start with `<?php` and return one static `[...]` or `array(...)` literal.

* Use quoted keys and string values. Nested arrays become dotted keys.

* Comments, ordering, whitespace, quote style, and array syntax are preserved by replacing existing value literals.

* Variables, function calls, constants, `declare(...)`, and interpolated double-quoted strings are rejected.

## Next steps

* [Check translations](/cli/commands/check) before committing generated files.
* [Local translation workflow](/cli/workflows/local-generation) explains repeat runs.
* [Browse all file formats](/cli/reference/formats/overview).

## Related formats

* [JSON localization](/cli/reference/formats/json)
* [YAML localization](/cli/reference/formats/yaml)
