Laravel
ShipEasyI18n integration for Laravel — @i18n Blade directive, i18n() helper function, Livewire component integration, and config publishing.
No composer package is required for basic usage. Drop the service provider into your app for the Blade directive and helper.
Script tag in layout
Add the loader to resources/views/layouts/app.blade.php:
{{-- resources/views/layouts/app.blade.php --}}
<head>
<title>@i18n('site.title')</title>
{{-- ... --}}
<script
src="https://cdn.i18n.shipeasy.ai/v1/loader.js"
data-key="{{ config('i18n.key') }}"
data-profile="{{ config('i18n.profile', 'en:prod') }}"
async
></script>
</head>
Service provider and config
Register the service provider in config/app.php (or via auto-discovery):
// config/app.php
'providers' => [
// ...
App\Providers\ShipEasyI18nServiceProvider::class,
],
Publish the config file:
php artisan vendor:publish --tag=i18n-config
This creates config/i18n.php:
return [
'key' => env('ShipEasyI18n_KEY', ''),
'profile' => env('ShipEasyI18n_PROFILE', 'en:prod'),
'cdn' => 'https://cdn.i18n.shipeasy.ai/v1/loader.js',
];
@i18n Blade directive
The directive renders a <span data-label="..."> placeholder:
<nav>
<a href="/">@i18n('nav.home')</a>
<a href="/account">@i18n('nav.account')</a>
<button type="submit">@i18n('checkout.submit')</button>
</nav>
{{-- With variables --}}
<h1>@i18n('user.greeting', ['name' => $user->name])</h1>
i18n() helper function
Use the i18n() helper anywhere PHP runs — controllers, mail templates, notifications:
// app/Http/Controllers/PageController.php
public function index()
{
return view('home', [
'pageTitle' => i18n('site.title'),
]);
}
// app/Mail/OrderConfirmation.php
public function build()
{
return $this->subject(i18n('email.order.subject'))
->view('emails.order-confirmation');
}
Livewire integration
In Livewire components, use the i18n() helper inside render() or blade templates:
// app/Livewire/CartSummary.php
class CartSummary extends Component
{
public function render()
{
return view('livewire.cart-summary', [
'submitLabel' => i18n('checkout.submit'),
]);
}
}
{{-- resources/views/livewire/cart-summary.blade.php --}}
<div>
<button wire:click="checkout">@i18n('checkout.submit')</button>
</div>
Livewire re-renders components on the server — using @i18n() in Livewire templates means label changes take effect without a client-side script.
For the full implementation spec including package source code and edge cases, see plans/frameworks/laravel.md in the repository.