1.0.6 • Published 10 months ago
@eduenano27/laravel-inertia-localization v1.0.6
Laravel + Inertia + React Localization
Install
npm install @eduenano27/laravel-inertia-localization
vite.config.js
import i18n from '@eduenano27/laravel-inertia-localization/vite';
export default defineConfig({
plugins: [
laravel({
input: [
'resources/css/app.scss',
'resources/js/app.tsx'
],
refresh: true,
}),
i18n(),
react(),
],
});
app.tsx
import { I18nComponent } from '@eduenano27/laravel-inertia-localization';
createInertiaApp({
title: (title) => `${title} - ${appName}`,
resolve: (name) => resolvePageComponent(`./pages/${name}.tsx`, import.meta.glob('./pages/**/*.tsx')),
setup({ el, App, props })
{
return createRoot(el).render(
<I18nComponent>
<App {...props} />
</I18nComponent>
);
}
});
app.tsx
import { trans } from "@eduenano27/laravel-inertia-localization";
export default function Example() {
return (
<h1>Example { trans('locale.key.example', { replace: 'Replace!!', two: 'Twoooo!!' }) }</h1>
);
}