1.0.6 • Published 10 months ago

@eduenano27/laravel-inertia-localization v1.0.6

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
10 months ago

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>
    );
}
1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago