PHPackages                             sematico/laravel-inertia-i18n - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. sematico/laravel-inertia-i18n

ActiveLibrary[Localization &amp; i18n](/categories/localization)

sematico/laravel-inertia-i18n
=============================

Bridge Laravel JSON translations with React apps built on Inertia.js

v0.1.0(yesterday)06↑2900%MITTypeScriptPHP ^8.2CI passing

Since Aug 6Pushed yesterdayCompare

[ Source](https://github.com/alessandrotesoro/laravel-inertia-i18n)[ Packagist](https://packagist.org/packages/sematico/laravel-inertia-i18n)[ Docs](https://github.com/alessandrotesoro/laravel-inertia-i18n)[ GitHub Sponsors](https://github.com/alessandrotesoro)[ RSS](/packages/sematico-laravel-inertia-i18n/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (13)Versions (3)Used By (0)

Laravel Inertia i18n
====================

[](#laravel-inertia-i18n)

[![Packagist Version](https://camo.githubusercontent.com/38fdd71a34dacb060400e83118c30cf7efe8cdee7c8663ad665a708b04f93da8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73656d617469636f2f6c61726176656c2d696e65727469612d6931386e3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sematico/laravel-inertia-i18n)[![npm version](https://camo.githubusercontent.com/692a110fe1a1a02ef44fc53a84113b6e77a654606315fc53e7c525976a210846/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f25343073656d617469636f2532466c61726176656c2d696e65727469612d6931386e2d72656163743f7374796c653d666c61742d737175617265)](https://www.npmjs.com/package/@sematico/laravel-inertia-i18n-react)[![CI](https://github.com/alessandrotesoro/laravel-inertia-i18n/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/alessandrotesoro/laravel-inertia-i18n/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/7d217ebb91a61cb4d98e70dee31eb08e0a5f71bc518ebd4151a73c6fb1191d00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75653f7374796c653d666c61742d737175617265)](LICENSE.md)

Share Laravel JSON translations with an Inertia.js React application. The Composer package loads locale files and exposes them as Inertia props; the React package provides translation hooks and component interpolation.

PackageInstall from`sematico/laravel-inertia-i18n`[Packagist](https://packagist.org/packages/sematico/laravel-inertia-i18n)`@sematico/laravel-inertia-i18n-react`[npm](https://www.npmjs.com/package/@sematico/laravel-inertia-i18n-react)Note

The React package reads an `i18n` prop shared by the Laravel service provider. Keep `` inside your Inertia app tree.

Requirements
------------

[](#requirements)

- PHP 8.2 or newer
- Laravel 11, 12, or 13
- `inertiajs/inertia-laravel` 3.x
- React 19 and `@inertiajs/react` 3.x

Installation
------------

[](#installation)

Install the backend package:

```
composer require sematico/laravel-inertia-i18n
```

The service provider registers itself through Laravel package discovery. Publish the configuration file only when you need to change its defaults:

```
php artisan vendor:publish --tag=inertia-i18n-config
```

Install the React package:

```
npm install @sematico/laravel-inertia-i18n-react
```

Backend setup
-------------

[](#backend-setup)

Create JSON files in Laravel's `lang` directory. The file name is the locale:

```
{
  "Welcome!": "Welcome!",
  "Hello, :name!": "Hello, :name!",
  "One item|:count items": "One item|:count items"
}
```

By default, the package shares this payload as `page.props.i18n`:

```
[
    'locale' => 'en',
    'fallbackLocale' => 'en',
    'translations' => [/* ... */],
]
```

For locale switching, add the middleware to the routes that should accept the `_locale` query parameter:

```
use Sematico\InertiaI18n\Http\Middleware\HandleLocale;

Route::middleware([HandleLocale::class])->group(function () {
    // localized routes
});
```

`HandleLocale` validates locale names and stores an accepted locale in the session. Set `supported_locales` in the config file to restrict the accepted list.

React setup
-----------

[](#react-setup)

Mount the provider once around the part of the tree that uses translations:

```
import type { ReactNode } from "react";
import { I18nProvider } from "@sematico/laravel-inertia-i18n-react";

export function AppShell({ children }: { children: ReactNode }) {
  return {children};
}
```

Use `t`, read the active locale, or request a locale reload:

```
import { useTranslation } from "@sematico/laravel-inertia-i18n-react";

export function Greeting() {
  const { t, locale, setLocale } = useTranslation();

  return (

      {t("Welcome!")}
      {t("Hello, :name!", { name: "Alex" })}
      Current locale: {locale}
       setLocale("es")}>
        Español

  );
}
```

`t()` supports Laravel-style plural forms and interpolation:

```
t("One item|:count items", { count: 3 });
t("{0} None|{1} One|[2,*] :count items", { count: 3 });
```

Use `Trans` when translated text contains named component tags:

```
import { Trans } from "@sematico/laravel-inertia-i18n-react";

;
```

Configuration
-------------

[](#configuration)

The published `config/inertia-i18n.php` file supports:

OptionDefaultPurpose`auto_share``true`Share translations through the service provider`prop_name``i18n`Name of the Inertia prop`lang_path``null`Custom directory containing `{locale}.json` files`supported_locales``null`Optional allow-list for `HandleLocale`Set `auto_share` to `false` when you want to call `translationProps()` from the `SharesTranslations` trait in your own Inertia middleware. If `prop_name` is changed, pass the same value to ``.

Public API
----------

[](#public-api)

- `I18nProvider` reads the configured translation payload from Inertia page props.
- `useTranslation()` returns `t`, `locale`, and `setLocale`.
- `Trans` supports `i18nKey`, `values`, `count`, `components`, and `as`.
- `InertiaI18n::translations()` loads the current locale and merges missing keys from the Laravel fallback locale.
- `InertiaI18n::toInertiaPayload()` returns the locale, fallback locale, and translations.
- `SharesTranslations` exposes the same payload for manual sharing.

Development
-----------

[](#development)

```
composer install
composer validate --strict
composer test
composer analyse
composer format -- --test

pnpm install --frozen-lockfile
pnpm typecheck
pnpm test:js
pnpm lint
pnpm build
npm pack --dry-run
```

The package build writes distributable files to `packages/react/dist`. The published npm package contains that build output plus the project README and license file.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 95.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af4bb5092564de3865e7e14ffa426b904cbd16f780999437d7f083a8bf916291?d=identicon)[alessandrotesoro](/maintainers/alessandrotesoro)

---

Top Contributors

[![alessandrotesoro](https://avatars.githubusercontent.com/u/1590958?v=4)](https://github.com/alessandrotesoro "alessandrotesoro (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

inertiajslaravellaravellocalizationi18ntranslationsinertiareact

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sematico-laravel-inertia-i18n/health.svg)

```
[![Health](https://phpackages.com/badges/sematico-laravel-inertia-i18n/health.svg)](https://phpackages.com/packages/sematico-laravel-inertia-i18n)
```

###  Alternatives

[outhebox/laravel-translations

Manage your Laravel translations with a beautiful UI. Add, edit, delete, import, and export translations with ease.

816104.7k](/packages/outhebox-laravel-translations)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React/Svelte) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

5031.3k](/packages/erag-laravel-lang-sync-inertia)[osama-98/laravel-enum-translatable

A Laravel package that provides translatable enum functionality with easy-to-use methods for working with enum values and their translations

561.4k](/packages/osama-98-laravel-enum-translatable)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3915.5k](/packages/rawilk-profile-filament-plugin)[elegantly/laravel-translator

All on one translations management for Laravel

6339.5k](/packages/elegantly-laravel-translator)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
