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
+69-74Lines changed: 69 additions & 74 deletions
Original file line number
Diff line number
Diff line change
@@ -50,90 +50,68 @@ php artisan erag:install-lang
50
50
51
51
This will publish:
52
52
53
-
* ✅ `config/lang-manager.php` — for customizing the language path
53
+
* ✅ `config/inertia-lang.php` — for customizing the language path
54
54
* ✅ `resources/js/composables/useLang.ts` — for Vue (if selected)
55
55
* ✅ `resources/js/hooks/useLang.tsx` — for React (if selected)
56
56
57
57
During installation, you'll be prompted to choose either **Vue** or **React** for your frontend framework.
58
58
59
59
---
60
60
61
-
## 🚀 Usage
61
+
## 🚀 Usage Guide: `syncLangFiles()`
62
62
63
-
### 🔟 Where to Use `syncLangFiles()`?
63
+
The `syncLangFiles()` function is a Laravel helper provided by this package. Use it inside your **controller methods** to load translation files and automatically **share them with your Vue or React frontend via Inertia.js**.
64
64
65
-
Call `syncLangFiles()`**inside your controller method****before rendering an Inertia view** to load necessary language files and share them with the frontend.
65
+
> ✅ Think of `syncLangFiles()`as a bridge between Laravel’s backend translations and your Inertia-powered frontend.
66
66
67
67
---
68
68
69
-
### 1️⃣ Load a Single File
69
+
### 🧪 How It Works
70
70
71
-
📍 **Example in Controller:**
71
+
Suppose you have the following language file:
72
72
73
-
```php
74
-
use Inertia\Inertia;
75
-
76
-
public function index()
77
-
{
78
-
syncLangFiles('auth'); // Load a single language file
79
-
80
-
return Inertia::render('Dashboard');
81
-
}
82
-
```
83
-
84
-
✅ This loads `resources/lang/{locale}/auth.php` and makes translations available to Vue or React components.
0 commit comments