Skip to content

Commit 4257006

Browse files
committed
feat: update README and remove vue/react composables in favor of npm package
- Updated README with new documentation and improved examples - Removed Vue and React composables/hooks from package - Added note for using @erag/lang-sync-inertia npm package - Updated InstallLang command and ServiceProvider accordingly
1 parent fd43ec6 commit 4257006

File tree

5 files changed

+26
-144
lines changed

5 files changed

+26
-144
lines changed

README.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ To publish the configuration and composables, run:
4343
php artisan erag:install-lang
4444
```
4545

46-
This will publish:
46+
---
47+
48+
# ⚠️ Required for Frontend (Vue/React)
49+
50+
To use translations on your frontend, **📦 you must install the NPM companion package**:
4751

48-
*`config/inertia-lang.php` — for customizing the language path
49-
*`resources/js/composables/useLang.ts` — for Vue (if selected)
50-
*`resources/js/hooks/useLang.tsx` — for React (if selected)
52+
```bash
53+
npm install @erag/lang-sync-inertia
54+
```
5155

52-
During installation, you'll be prompted to choose either **Vue** or **React** for your frontend framework.
56+
📘 Full frontend documentation:
57+
[https://www.npmjs.com/package/@erag/lang-sync-inertia](https://www.npmjs.com/package/@erag/lang-sync-inertia)
5358

5459
---
5560

@@ -135,20 +140,20 @@ public function login()
135140
</template>
136141
137142
<script setup>
138-
import { useLang } from '@/composables/useLang'
143+
import { vueLang } from '@erag/lang-sync-inertia'
139144
140-
const { trans, __ } = useLang()
145+
const { trans, __ } = vueLang()
141146
</script>
142147
```
143148

144149
#### ✅ React Example
145150

146151
```tsx
147152
import React from 'react'
148-
import { useLang } from '@/hooks/useLang'
153+
import { reactLang } from '@erag/lang-sync-inertia'
149154

150155
export default function Login() {
151-
const { trans, __ } = useLang()
156+
const { trans, __ } = reactLang()
152157

153158
return (
154159
<div>
@@ -258,12 +263,10 @@ return [
258263

259264
---
260265

261-
## 🧩 Composables Location
262-
263-
* **Vue:** `resources/js/composables/useLang.ts`
264-
* **React:** `resources/js/hooks/useLang.tsx`
266+
## 🧩 Through:
265267

266-
You can modify the location or structure of these files by adjusting the published files.
268+
* `vueLang()` — Vue 3
269+
* `reactLang()` — React
267270

268271
---
269272

resources/js/composables/useLang.ts

Lines changed: 0 additions & 49 deletions
This file was deleted.

resources/js/hooks/useLang.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/Commands/InstallLang.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace LaravelLangSyncInertia\Commands;
44

55
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\Process;
67

78
class InstallLang extends Command
89
{
@@ -20,32 +21,16 @@ public function handle()
2021
$this->info('✅ Configuration published successfully.');
2122
$this->newLine();
2223

23-
// Ask for frontend framework
24-
$choice = $this->choice(
25-
'🎯 Which frontend framework are you using?',
26-
['Vue.js', 'React.js'],
27-
0
28-
);
29-
30-
if ($choice === 'Vue.js') {
31-
$this->info('📦 Publishing Vue composable...');
32-
$this->call('vendor:publish', [
33-
'--tag' => 'erag:publish-lang-composable-vue',
34-
'--force' => true,
35-
]);
36-
$this->info('✅ Vue composable published successfully.');
37-
}
24+
$this->info('📦 Installing frontend helper via NPM...');
25+
26+
$result = Process::run('npm install @erag/lang-sync-inertia');
3827

39-
if ($choice === 'React.js') {
40-
$this->info('📦 Publishing React composable...');
41-
$this->call('vendor:publish', [
42-
'--tag' => 'erag:publish-lang-composable-react',
43-
'--force' => true,
44-
]);
45-
$this->info('✅ React composable published successfully.');
28+
if ($result->successful()) {
29+
$this->info('✅ NPM package installed successfully.');
30+
} else {
31+
$this->error('❌ Failed to install NPM package.');
32+
$this->line($result->errorOutput());
4633
}
4734

48-
$this->newLine();
49-
$this->info('🎉 LaravelLangSyncInertia installation completed!');
5035
}
5136
}

src/LangSyncInertiaServiceProvider.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ protected function publishConfig(): void
4848
__DIR__.'/../config/inertia-lang.php' => config_path('inertia-lang.php'),
4949
], 'erag:publish-lang-config');
5050

51-
$this->publishes([
52-
__DIR__.'/../resources/js/composables/useLang.ts' => resource_path('js/composables/useLang.ts'),
53-
], 'erag:publish-lang-composable-vue');
54-
55-
$this->publishes([
56-
__DIR__.'/../resources/js/hooks/useLang.tsx' => resource_path('js/hooks/useLang.tsx'),
57-
], 'erag:publish-lang-composable-react');
58-
5951
}
6052

6153
protected function loadHelpers(): void

0 commit comments

Comments
 (0)