diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index d43d301..a35eeb6 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -46,6 +46,10 @@ class HandleInertiaRequests extends Middleware return [ ...parent::share($request), 'name' => config('app.name'), + 'localization' => [ + 'locale' => app()->getLocale(), + 'timeZone' => config('app.timezone'), + ], 'auth' => [ 'permissions' => [ 'canManageTeams' => $user !== null && ($this->permissionService->canManageAnyTeam($user) || $this->permissionService->allows($user, Permission::TeamCreate)), diff --git a/resources/js/app.ts b/resources/js/app.ts index c098682..0d6194e 100644 --- a/resources/js/app.ts +++ b/resources/js/app.ts @@ -4,6 +4,7 @@ import type { DefineComponent } from 'vue'; import { createApp, h } from 'vue'; import '../css/app.css'; import { initializeTheme } from '@/composables/useAppearance'; +import { createLocalization } from '@/lib/localization'; const appName = import.meta.env.VITE_APP_NAME || 'Laravel'; @@ -17,6 +18,7 @@ createInertiaApp({ setup({ el, App, props, plugin }) { createApp({ render: () => h(App, props) }) .use(plugin) + .use(createLocalization(props.initialPage.props.localization)) .mount(el); }, progress: { diff --git a/resources/js/components/AlertError.vue b/resources/js/components/AlertError.vue index c05937d..3849851 100644 --- a/resources/js/components/AlertError.vue +++ b/resources/js/components/AlertError.vue @@ -2,15 +2,15 @@ import { AlertCircle } from 'lucide-vue-next'; import { computed } from 'vue'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; +import { useLocalization } from '@/composables/useLocalization'; type Props = { errors: string[]; title?: string; }; -const props = withDefaults(defineProps(), { - title: 'Something went wrong.', -}); +const props = defineProps(); +const { t } = useLocalization(); const uniqueErrors = computed(() => Array.from(new Set(props.errors))); @@ -18,7 +18,7 @@ const uniqueErrors = computed(() => Array.from(new Set(props.errors)));