Skip to main content
Glama
installIntlayer.ts1.39 kB
import configuration from '@intlayer/config/built'; import type { Locale, LocalesValues } from '@intlayer/types'; import { type App, type Ref, readonly, ref } from 'vue'; import { installIntlayerEditor } from '../editor'; export const INTLAYER_SYMBOL = Symbol('intlayer'); /** * Singleton instance */ let instance: IntlayerProvider | null = null; export type IntlayerProvider = { locale: Ref<Locale>; setLocale: (locale: LocalesValues) => void; isCookieEnabled?: boolean; }; /** * Create and return a single IntlayerProvider instance */ export const createIntlayerClient = ( locale?: LocalesValues, isCookieEnabled = true ): IntlayerProvider => { if (instance) return instance; const { defaultLocale } = configuration.internationalization ?? {}; const targetLocale = ref<Locale>((locale as Locale) ?? defaultLocale); const setLocale = (newLocale: LocalesValues) => { targetLocale.value = newLocale as Locale; }; instance = { locale: readonly(targetLocale), setLocale, isCookieEnabled, }; return instance; }; /** * Helper to install the Intlayer provider into the app */ export const installIntlayer = ( app: App, locale?: LocalesValues, isCookieEnabled = true ) => { const client = createIntlayerClient(locale, isCookieEnabled); app.provide(INTLAYER_SYMBOL, client); installIntlayerEditor(app, client); return app; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server