# HasTranslate

> Provides an immutable API for the translate attribute.

[API reference](/docs/api/index.md) › [HTML Attribute](/docs/extensions/html-attribute/reference/index.md) › [Global](/docs/extensions/html-attribute/reference/global/index.md) › HasTranslate

| trait | `UIAwesome\Html\Attribute\Global\HasTranslate` |
| --- | --- |
| Source | [`src/Global/HasTranslate.php`](https://github.com/ui-awesome/html-attribute/blob/main/src/Global/HasTranslate.php#L21) |

Used by 4 types:

- [`UIAwesome\Html\Core\Element\BaseBlock`](/docs/extensions/html-core/reference/element/baseblock/index.md)
- [`UIAwesome\Html\Core\Element\BaseInline`](/docs/extensions/html-core/reference/element/baseinline/index.md)
- [`UIAwesome\Html\Core\Element\BaseInput`](/docs/extensions/html-core/reference/element/baseinput/index.md)
- [`UIAwesome\Html\Core\Element\BaseVoid`](/docs/extensions/html-core/reference/element/basevoid/index.md)

Provides an immutable API for the `translate` attribute.

See also: <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate>.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`translate()`](#method-translate) | Sets the `translate` attribute. | `HasTranslate` |

## Method details

### translate() <span id="method-translate"></span>

```php
public function translate(bool|string|UnitEnum|null $value): static
```

Sets the `translate` attribute.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `bool\|string\|`[`UnitEnum`](https://www.php.net/manual/en/class.unitenum.php)`\|null` | Translation behavior. Use 'yes', 'no', `true`, `false`, or `null` to remove the attribute. |

**Returns**

`static`: New instance with the updated `translate` attribute. [`Translate`](/docs/extensions/html-attribute/reference/values/translate/index.md) for predefined enum values.

**Throws**

- [`InvalidArgumentException`](https://www.php.net/manual/en/class.invalidargumentexception.php): If the value is not valid.