# Translate

Retrieve a string from a language file in the current locale.


This tag is the equivalent of the [trans and trans_choice methods](https://laravel.com/docs/localization) provided by Laravel.

:::tip
There's also a [modifier](/modifiers/trans.md) version that you may prefer.
:::

## Usage

Get the `bar` string from the `lang/en/foo.php` translation file (where `en` is the current locale).

```php
<?php
return [
    'bar' => 'Bar!',
    'welcome' => 'Welcome, :name!',
    'apples' => 'There is one apple|There are :count apples',
];
```

::tabs

::tab antlers
```antlers
{{ trans:foo.bar }} or {{ trans key="foo.bar" }}
```
::tab blade
```blade
{{ trans('foo.bar') or {{ __('foo.bar') }}
```
::

```html
Bar!
```

## Replacements

Any additional tag parameters will be treated as parameters that should be replaced in the string.

::tabs

::tab antlers
```antlers
{{ trans:foo.welcome name="Bob" }}
```
::tab blade
```blade
{{ trans('foo.welcome', ['name' => 'Bob']) }}
```
::

```html
Welcome, Bob!
```

## Pluralization

To pluralize, use the `trans_choice` tag with a `count` parameter.

::tabs

::tab antlers
```antlers
{{ trans_choice:foo.apples count="2" }}
```
::tab blade
```blade
{{ trans_choice('foo.apples', 2) }}
```
::

```html
There are 2 apples
```

## Fallback

Provide a `fallback` parameter to use when the translation key doesn't exist. The fallback can be either a literal string or another translation key.

```antlers
{{ trans key="messages.does_not_exist" fallback="Literal fallback" }}
```

```html
Literal fallback
```

If the fallback itself is a valid translation key, that translation will be used instead.

```antlers
{{ trans key="messages.does_not_exist" fallback="messages.fallback_key" }}
```

```html
Fallback from existing key
```

Parameter replacements are also applied to the fallback.

```antlers
{{ trans key="messages.does_not_exist" name="Bob" fallback="Hello, :name" }}
```

```html
Hello, Bob
```
