Skip to content

Commit cdfd821

Browse files
committed
chore: update version to 0.0.7 in package.json and package-lock.json; remove langPath option from useLocalizer hook
1 parent c7b4ca9 commit cdfd821

File tree

3 files changed

+7
-38
lines changed

3 files changed

+7
-38
lines changed

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devwizard/laravel-localizer-react",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"type": "module",
55
"description": "React integration for Laravel Localizer with Vite plugin, useLocalizer hook, and automatic TypeScript generation",
66
"main": "dist/index.js",

src/useLocalizer.ts

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -107,22 +107,6 @@ export interface UseLocalizerReturn {
107107
getLocales: () => string[];
108108
}
109109

110-
/**
111-
* Options for useLocalizer hook
112-
*/
113-
export interface UseLocalizerOptions {
114-
/**
115-
* Custom path to translations directory
116-
* @default '@/lang'
117-
* @example
118-
* ```tsx
119-
* // Use custom path
120-
* const { __ } = useLocalizer({ langPath: '@/translations' });
121-
* ```
122-
*/
123-
langPath?: string;
124-
}
125-
126110
/**
127111
* Replace placeholders in translation strings
128112
*
@@ -149,10 +133,8 @@ function replacePlaceholders(text: string, replacements?: Replacements): string
149133
/**
150134
* React hook for translations
151135
*
152-
* By default, translations are read from '@/lang' folder (resources/js/lang).
153-
* You can customize this by passing a langPath option.
136+
* Translations are read from window.localizer which is initialized in bootstrap.ts.
154137
*
155-
* @param options - Configuration options for the localizer
156138
* @returns Translation utilities and locale information
157139
*
158140
* @example
@@ -171,28 +153,15 @@ function replacePlaceholders(text: string, replacements?: Replacements): string
171153
* );
172154
* }
173155
* ```
174-
*
175-
* @example
176-
* ```tsx
177-
* // Custom translations path
178-
* function MyComponent() {
179-
* const { __ } = useLocalizer({ langPath: '@/translations' });
180-
*
181-
* return <h1>{__('welcome')}</h1>;
182-
* }
183-
* ```
184156
*/
185-
export function useLocalizer(options: UseLocalizerOptions = {}): UseLocalizerReturn {
186-
const { langPath = '@/lang' } = options;
157+
export function useLocalizer(): UseLocalizerReturn {
187158
const { props } = usePage<PageProps>();
188159
const locale = props.locale?.current || 'en';
189160
const dir = props.locale?.dir || 'ltr';
190161

191162
const availableLocales = useMemo(() => props.locale?.available || {}, [props.locale?.available]);
192163

193164
// Load translations from window object (initialized in bootstrap.ts)
194-
// The langPath option is used by the vite plugin to know where to watch for changes
195-
// and where the generated files should be located
196165
const translations = useMemo<Record<string, string>>(() => {
197166
try {
198167
// Translations are automatically loaded in bootstrap.ts from the generated files
@@ -206,7 +175,7 @@ export function useLocalizer(options: UseLocalizerOptions = {}): UseLocalizerRet
206175

207176
if (!localizer?.translations) {
208177
console.warn(
209-
`[Laravel Localizer] Translations not initialized. Make sure bootstrap.ts imports from '${langPath}'.`
178+
'[Laravel Localizer] Translations not initialized. Make sure bootstrap.ts imports translations.'
210179
);
211180
return {};
212181
}
@@ -219,7 +188,7 @@ export function useLocalizer(options: UseLocalizerOptions = {}): UseLocalizerRet
219188
);
220189
return {};
221190
}
222-
}, [locale, langPath]);
191+
}, [locale]);
223192

224193
/**
225194
* Main translation function

0 commit comments

Comments
 (0)