You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+60-13Lines changed: 60 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,11 @@
8
8
9
9
LaravelLangSyncInertia is the perfect solution for Laravel developers using Inertia.js with Vue or React. It helps you:
10
10
11
-
✅ Easily manage language files
12
-
✅ Dynamically sync translations with Inertia.js
13
-
✅ Reduce boilerplate for loading translations
14
-
✅ Automatically share translations with all pages
15
-
✅ Improve performance with smart caching
11
+
✅ Easily manage language files
12
+
✅ Dynamically sync translations with Inertia.js
13
+
✅ Reduce boilerplate for loading translations
14
+
✅ Automatically share translations with all pages
15
+
✅ Improve performance with smart caching
16
16
17
17
---
18
18
@@ -33,7 +33,7 @@ Install the package via Composer:
33
33
34
34
```bash
35
35
composer require erag/laravel-lang-sync-inertia
36
-
````
36
+
```
37
37
38
38
---
39
39
@@ -54,25 +54,74 @@ This publishes:
54
54
55
55
## 🚀 Usage
56
56
57
+
### 🔟 Where to Use `lang_file_load()`?
58
+
59
+
Call `lang_file_load()`**inside your controller method****before returning an Inertia view**. This ensures the necessary language files are loaded and shared with the frontend.
60
+
61
+
---
62
+
57
63
### 1️⃣ Load a Single File
58
64
65
+
📍 **Example in Controller:**
66
+
59
67
```php
60
-
lang_file_load('auth');
68
+
use Inertia\Inertia;
69
+
70
+
public function index()
71
+
{
72
+
lang_file_load('auth'); // Load a single language file
73
+
74
+
return Inertia::render('Dashboard');
75
+
}
61
76
```
62
77
78
+
✅ This loads `resources/lang/{locale}/auth.php` and makes the translations available to your Vue or React component.
0 commit comments