Skip to content

Commit 2e0541a

Browse files
committed
chore: update documentation and configuration for improved clarity and functionality
1 parent 6718907 commit 2e0541a

File tree

9 files changed

+63
-48
lines changed

9 files changed

+63
-48
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,27 @@ All notable changes to `@devwizard/laravel-localizer-vue` will be documented in
3434
- Automatic page props detection
3535

3636
### 📚 Documentation
37+
3738
- Comprehensive README with usage examples
3839
- API documentation with TypeScript interfaces
3940
- Migration guide from v1 to v2
4041

4142
### 🧪 Testing
43+
4244
- Vitest configuration
4345
- Comprehensive test suite with 100% coverage
4446
- Vue Test Utils for component testing
4547
- ESM module support
4648

4749
### 🛠️ Development Tools
50+
4851
- ESLint configuration with TypeScript and Vue rules
4952
- Prettier for code formatting
5053
- tsup for building and bundling
5154
- GitHub Actions for CI/CD
5255

5356
### 📦 Package Configuration
57+
5458
- ESM-only distribution
5559
- Tree-shakeable exports
5660
- Proper package.json exports field

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ yarn add @devwizard/laravel-localizer-vue
2323
```
2424

2525
**Backend (Composer):**
26+
2627
```bash
2728
composer require devwizardhq/laravel-localizer
2829
php artisan localizer:install --framework=vue
@@ -167,18 +168,18 @@ const { translations, locale } = useTranslation();
167168

168169
Returns an object with the following properties and methods:
169170

170-
| Property | Type | Description |
171-
|----------|------|-------------|
172-
| `__` | `(key, replacements?, fallback?) => string` | Main translation function |
173-
| `trans` | `(key, replacements?, fallback?) => string` | Alias for `__` |
174-
| `lang` | `(key, replacements?, fallback?) => string` | Alias for `__` |
175-
| `has` | `(key) => boolean` | Check if translation key exists |
176-
| `choice` | `(key, count, replacements?) => string` | Pluralization support |
177-
| `locale` | `ComputedRef<string>` | Current locale code (reactive) |
178-
| `dir` | `ComputedRef<'ltr' \| 'rtl'>` | Text direction (reactive) |
179-
| `availableLocales` | `ComputedRef<Record<string, LocaleInfo>>` | Available locales with metadata (reactive) |
180-
| `translations` | `ComputedRef<Record<string, string>>` | All translations for current locale (reactive) |
181-
| `getLocales` | `() => string[]` | Get all available locale codes |
171+
| Property | Type | Description |
172+
| ------------------ | ------------------------------------------- | ---------------------------------------------- |
173+
| `__` | `(key, replacements?, fallback?) => string` | Main translation function |
174+
| `trans` | `(key, replacements?, fallback?) => string` | Alias for `__` |
175+
| `lang` | `(key, replacements?, fallback?) => string` | Alias for `__` |
176+
| `has` | `(key) => boolean` | Check if translation key exists |
177+
| `choice` | `(key, count, replacements?) => string` | Pluralization support |
178+
| `locale` | `ComputedRef<string>` | Current locale code (reactive) |
179+
| `dir` | `ComputedRef<'ltr' \| 'rtl'>` | Text direction (reactive) |
180+
| `availableLocales` | `ComputedRef<Record<string, LocaleInfo>>` | Available locales with metadata (reactive) |
181+
| `translations` | `ComputedRef<Record<string, string>>` | All translations for current locale (reactive) |
182+
| `getLocales` | `() => string[]` | Get all available locale codes |
182183

183184
## Vite Plugin Options
184185

@@ -227,8 +228,8 @@ The package is fully typed. Generated translation files include TypeScript defin
227228
```typescript
228229
// Generated by localizer:generate
229230
export const en = {
230-
"welcome": "Welcome",
231-
"validation.required": "This field is required",
231+
welcome: 'Welcome',
232+
'validation.required': 'This field is required',
232233
} as const;
233234

234235
export type TranslationKeys = keyof typeof en;

composables/useTranslation.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ export interface UseTranslationReturn {
9494
/**
9595
* Available locales with metadata (reactive)
9696
*/
97-
availableLocales: ComputedRef<Record<string, { label: string; flag: string; dir: 'ltr' | 'rtl' }>>;
97+
availableLocales: ComputedRef<
98+
Record<string, { label: string; flag: string; dir: 'ltr' | 'rtl' }>
99+
>;
98100

99101
/**
100102
* All translations for current locale (reactive)
@@ -157,9 +159,7 @@ export function useTranslation(): UseTranslationReturn {
157159

158160
const locale = computed(() => page.props.locale?.current || 'en');
159161
const dir = computed(() => page.props.locale?.dir || 'ltr');
160-
const availableLocales = computed(
161-
() => page.props.locale?.available || {}
162-
);
162+
const availableLocales = computed(() => page.props.locale?.available || {});
163163

164164
// Dynamically import translations from generated files
165165
// Note: Users need to set up path alias '@/lang' -> 'resources/js/lang'
@@ -171,7 +171,9 @@ export function useTranslation(): UseTranslationReturn {
171171
interface WindowWithTranslations extends Window {
172172
__LARAVEL_LOCALIZER_TRANSLATIONS__?: Record<string, Record<string, string>>;
173173
}
174-
return (window as WindowWithTranslations).__LARAVEL_LOCALIZER_TRANSLATIONS__?.[locale.value] || {};
174+
return (
175+
(window as WindowWithTranslations).__LARAVEL_LOCALIZER_TRANSLATIONS__?.[locale.value] || {}
176+
);
175177
} catch {
176178
console.warn(`[Laravel Localizer] Could not load translations for locale: ${locale.value}`);
177179
return {};

eslint.config.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
import js from '@eslint/js';
22
import tseslint from 'typescript-eslint';
33
import vuePlugin from 'eslint-plugin-vue';
4-
import vueParser from 'vue-eslint-parser';
54

65
export default tseslint.config(
76
js.configs.recommended,
87
...tseslint.configs.recommended,
98
...vuePlugin.configs['flat/recommended'],
109
{
11-
files: ['**/*.ts', '**/*.vue'],
12-
languageOptions: {
13-
parser: vueParser,
14-
parserOptions: {
15-
parser: tseslint.parser,
16-
extraFileExtensions: ['.vue'],
17-
},
18-
},
10+
files: ['**/*.ts', '**/*.tsx', '**/*.vue'],
1911
rules: {
2012
'@typescript-eslint/no-explicit-any': 'warn',
2113
'@typescript-eslint/no-unused-vars': [
@@ -29,7 +21,7 @@ export default tseslint.config(
2921
},
3022
},
3123
{
32-
files: ['**/__tests__/**'],
24+
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
3325
rules: {
3426
'@typescript-eslint/no-explicit-any': 'off',
3527
},

eslint.config.min.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
import js from"@eslint/js";import tseslint from"typescript-eslint";import vuePlugin from"eslint-plugin-vue";import vueParser from"vue-eslint-parser";export default tseslint.config(js.configs.recommended,...tseslint.configs.recommended,...vuePlugin.configs["flat/recommended"],{files:["**/*.ts","**/*.vue"],languageOptions:{parser:vueParser,parserOptions:{parser:tseslint.parser,extraFileExtensions:[".vue"]}},rules:{"@typescript-eslint/no-explicit-any":"warn","@typescript-eslint/no-unused-vars":["error",{argsIgnorePattern:"^_",varsIgnorePattern:"^_"}],"vue/multi-word-component-names":"off"}},{files:["**/__tests__/**"],rules:{"@typescript-eslint/no-explicit-any":"off"}},{ignores:["dist/**","node_modules/**","coverage/**","*.config.*","eslint.config.js"]});
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import vuePlugin from 'eslint-plugin-vue';
4+
export default tseslint.config(
5+
js.configs.recommended,
6+
...tseslint.configs.recommended,
7+
...vuePlugin.configs['flat/recommended'],
8+
{
9+
files: ['**/*.ts', '**/*.tsx', '**/*.vue'],
10+
rules: {
11+
'@typescript-eslint/no-explicit-any': 'warn',
12+
'@typescript-eslint/no-unused-vars': [
13+
'error',
14+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
15+
],
16+
'vue/multi-word-component-names': 'off',
17+
},
18+
},
19+
{
20+
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
21+
rules: { '@typescript-eslint/no-explicit-any': 'off' },
22+
},
23+
{ ignores: ['dist/**', 'node_modules/**', 'coverage/**', '*.config.*', 'eslint.config.js'] }
24+
);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
"homepage": "https://github.com/DevWizardHQ/laravel-localizer#readme",
8080
"peerDependencies": {
8181
"@inertiajs/vue3": "^1.0.0 || ^2.0.0",
82-
"vue": "^3.0.0",
83-
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
82+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
83+
"vue": "^3.0.0"
8484
},
8585
"devDependencies": {
8686
"@eslint/js": "^9.17.0",
@@ -96,6 +96,7 @@
9696
"typescript-eslint": "^8.41.0",
9797
"vite": "^7.2.2",
9898
"vitest": "^4.0.8",
99-
"vue": "^3.5.13"
99+
"vue": "^3.5.13",
100+
"vue-eslint-parser": "^10.2.0"
100101
}
101102
}

tsconfig.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@
3737
"noUncheckedIndexedAccess": true,
3838
"skipLibCheck": true
3939
},
40-
"include": [
41-
"**/*.ts",
42-
"**/*.tsx"
43-
],
44-
"exclude": [
45-
"node_modules",
46-
"dist",
47-
"__tests__",
48-
"**/*.test.ts"
49-
]
40+
"include": ["**/*.ts", "**/*.tsx"],
41+
"exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts"]
5042
}

vite-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ export interface LocalizerPluginOptions {
3232

3333
/**
3434
* Vite plugin for Laravel Localizer
35-
*
35+
*
3636
* Automatically regenerates TypeScript translation files when Laravel language files change.
37-
*
37+
*
3838
* @example
3939
* ```ts
4040
* import { defineConfig } from 'vite';
4141
* import { laravelLocalizer } from '@devwizard/laravel-localizer-vue/vite';
42-
*
42+
*
4343
* export default defineConfig({
4444
* plugins: [
4545
* laravelLocalizer({

0 commit comments

Comments
 (0)