trypost/resources/js/app.ts
Paulo Castellano e17b86ac93 Make the content-language field a searchable combobox and reload on UI-language switch
Replace the plain content-language <Select> in the brand form with a
searchable LanguagePicker combobox (Popover + Command), matching the
FontPicker. i18n the combobox placeholder/search/empty strings across all
15 locales.

Switch the UI language via a full page reload instead of client-side dir
syncing, so the server-rendered <html dir> flips LTR<->RTL correctly
without a manual refresh.
2026-07-03 18:17:38 -03:00

70 lines
2.4 KiB
TypeScript

import '../css/app.css';
import './echo';
import { createInertiaApp, router } from '@inertiajs/vue3';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { i18nVue } from 'laravel-vue-i18n';
import type { DefineComponent } from 'vue';
import { createApp, h } from 'vue';
import { initializeDataLayer } from './datalayer';
import dayjs from './dayjs';
import { capturePageview, initializePostHog, syncPostHogContext } from './posthog';
import type { Auth } from './types';
const appName = import.meta.env.VITE_APP_NAME || 'TryPost.it';
createInertiaApp({
title: (title) => (title ? `${title} - ${appName}` : appName),
resolve: (name) =>
resolvePageComponent(
`./pages/${name}.vue`,
import.meta.glob<DefineComponent>('./pages/**/*.vue'),
),
setup({ el, App, props, plugin }) {
// Get locale from shared Inertia props
const locale = (props.initialPage.props as { locale?: string })?.locale || 'en';
// Set dayjs locale based on user's language
dayjs.locale(locale.toLowerCase());
const auth = props.initialPage.props.auth as Auth | undefined;
const flash = props.initialPage.props.flash as
| { conversion_event?: string; [key: string]: unknown }
| undefined;
initializeDataLayer(
auth,
flash,
props.initialPage.props.applicationUrl as string,
props.initialPage.props.env as string,
);
// Initial PostHog identify + dual-group context + first pageview.
// The same hooks fire on every Inertia navigation below so the
// account group counts stay reactive and workspace switches
// re-attach the right workspace group.
initializePostHog();
syncPostHogContext(props.initialPage);
capturePageview();
router.on('navigate', (event) => {
syncPostHogContext(event.detail.page);
capturePageview();
});
createApp({ render: () => h(App, props) })
.use(i18nVue, {
lang: locale,
resolve: async (lang: string) => {
const langs = import.meta.glob('../../lang/*.json');
return await langs[`../../lang/php_${lang}.json`]();
},
})
.use(plugin)
.mount(el);
},
progress: {
color: '#4B5563',
},
});