Skip to main content
Internationalization framework for Laravel

FBT for Laravel

Translate whole sentences, with plurals, genders and names, so that your Laravel app reads naturally in every language.

composer require richarddobron/laravel-fbt

FBT in action

Write the text once in English. Translators get whole sentences with the variations their language needs, and FBT picks the right one at runtime.

Blade
<fbt desc="Unread messages in the inbox">
You have
<fbt:plural count="{{ $count }}" name="count"
showCount="yes" many="unread messages">
unread message
</fbt:plural>.
</fbt>
Output · Slovenčina
  • $count = 1
    Máš 1 neprečítanú správu.
  • $count = 3
    Máš 3 neprečítané správy.
  • $count = 5
    Máš 5 neprečítaných správ.
  • $count = 21
    Máš 21 neprečítaných správ.

English and German have two forms. Slovak has three (1, 2–4, 5+), Russian uses the form of 1 also for 21, Turkish keeps the noun singular after a number, and Japanese has no plural at all. Translators just fill in the forms of their language.

HTML fbts are rendered in @fbtTransform … @endFbtTransform. The outputs above are rendered by laravel-fbt.

Why FBT?

Getting grammatically correct translations in dynamic applications is hard. Let FBT do the hard work.

Inline translations

Write texts right where they're used, in Blade with @fbt or in PHP with fbt(). No translation keys, no language files to keep in sync.

Grammar done right

Plurals, genders and names are variations translators fill in. Every language gets correct sentences, even with three plural forms or gendered verbs.

Proven at Facebook

A port of fbt, the framework Facebook built to translate its apps. Same source strings, same translation formats.

Easy setup

One Composer package, artisan commands to collect and translate texts. Store translations in JSON files or in the database.

Translate in context

Inline translating lets translators edit texts right on the page, where they see how they're used.

Built for Laravel

Blade directives, the locale of the application, the signed-in user as viewer context, and clean state for Octane requests and queued jobs.

Get started in minutes

Keep translations in JSON files, or in the database.

composer require richarddobron/laravel-fbt
php artisan vendor:publish --tag=fbt-config

# Wrap texts with @fbt(...), then collect them
php artisan fbt:collect-fbts
php artisan fbt:generate-translations

# Translate storage/fbt/translation_input.json, then
php artisan fbt:translate

Read the full guide →

Let your coding agent set it up

Paste this prompt into Claude Code, Cursor or Copilot, it installs laravel-fbt and wraps the texts of your app.

Prompt
Add internationalization to this Laravel app with laravel-fbt (docs: https://richarddobron.github.io/laravel-fbt/).

1. Install it with `composer require richarddobron/laravel-fbt` and publish the configuration with
`php artisan vendor:publish --tag=fbt-config`.
2. In config/fbt.php, set `author` and `project`, and set `locale` to `laravel`, so that fbt follows the locale
of the application. Keep the `json` driver (translations in storage/fbt), or set `driver` to `eloquent` and run
`php artisan migrate` to keep phrases and translations in the database.
3. Make the User model implement `fbt\Lib\IntlViewerContextInterface` (`getLocale()` and `getGender()`), so that
texts use the locale and the gender of the signed-in user.
4. Wrap every user-facing text:
- in Blade: `@fbt('Text', 'Description')`, or `<fbt desc="Description">Text</fbt>` inside
`@fbtTransform` ... `@endFbtTransform`,
- in PHP: `fbt('Text', 'Description')`, and `fbs()` for plain text (e.g. HTML attributes).
Every text needs a description which explains its context to translators.
5. Never concatenate translated fragments, keep whole sentences in one fbt. Use `fbt::param()` / `<fbt:param>` for
values, `fbt::plural()` / `<fbt:plural>` for counts, `fbt::name()` / `<fbt:name>` for names of people (with
their gender), `fbt::enum()` and `fbt::pronoun()`.
6. Collect the texts with `php artisan fbt:collect-fbts`, generate the missing translations with
`php artisan fbt:generate-translations` (json driver) and build the translations with `php artisan fbt:translate`.

Based on Facebook's fbt

Facebook