@larasell-dev/inertia-i18n
v0.1.1
Published
Minimal Laravel translation support for Inertia applications
Readme
@larasell-dev/inertia-i18n
Minimal Laravel translation support for Inertia applications. Laravel PHP translation files are compiled by Vite into lazy locale and namespace chunks.
// vite.config.ts
import { i18n } from '@larasell-dev/inertia-i18n/vite'
export default defineConfig({
plugins: [laravel(), i18n()],
})// resources/js/app.tsx
import { createI18n } from '@larasell-dev/inertia-i18n/react'
const i18n = createI18n({ global: ['common'] })
createInertiaApp({
resolve: i18n.resolve(import.meta.glob('./Pages/**/*.tsx')),
withApp: i18n.withApp,
})Pages declare their own namespaces:
import { useTranslation } from '@larasell-dev/inertia-i18n/react'
function Orders() {
const { t, choice } = useTranslation()
return <h1>{t('orders.title')}</h1>
}
Orders.translation = ['orders']
export default Orders