PHP code example of codecng / laravel-inertia-translations

1. Go to this page and download the library: Download codecng/laravel-inertia-translations library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codecng / laravel-inertia-translations example snippets


public function share(Request $request): array
{
    return array_merge(parent::share($request), [
        'language' => request()->user()->language ?? app()->getLocale(),
    ]);
}
bash
php artisan translate
typescript
// The __ function is fully typed
__('welcome.title') // ✓ Valid
__('invalid.key')   // ✗ TypeScript error