Laravel-native flow
Call `syncLangFiles()` in your controller and let Inertia share translations automatically.
Load backend language files once, access them anywhere on the frontend with clean helpers and placeholder support.
The backend decides which language files should be available for the page. After that, your frontend can read translations with a very small API.
syncLangFiles() in the controller.lang() in Vue or React.__() or trans().<?php
namespace App\Http\Controllers;
use Inertia\Inertia;
use Inertia\Response;
class DashboardController extends Controller
{
public function index(): Response
{
syncLangFiles(['auth', 'dashboard']);
return Inertia::render('Dashboard');
}
}<script setup>
import { lang } from '@erag/lang-sync-inertia/vue'
const { __, trans } = lang()
</script>
<template>
<h1>{{ __('auth.greeting') }}</h1>
<p>{{ trans('auth.welcome', { name: 'Amit' }) }}</p>
</template>import { lang } from '@erag/lang-sync-inertia/react'
export default function Dashboard() {
const { __, trans } = lang()
return (
<section>
<h1>{__('auth.greeting')}</h1>
<p>{trans('auth.welcome', { name: 'Amit' })}</p>
</section>
)
}Choose the package you want to install first.
composer require erag/laravel-lang-sync-inertia
php artisan lang:publish
php artisan erag:install-langnpm install @erag/lang-sync-inertiaLaravel Lang Sync Inertia connects Laravel translation files to your Inertia frontend without manually passing props in every response.
This package is useful when: