Configuration
Understanding and utilizing Vay's configuration options allows you to customize the library to suit your project's needs.
Configuration Properties
targetAttribute
(type:string
): The attribute Vay.js uses to mark elements for translation. Defaults to'vay'
.ignoreAttributes
(type:boolean
): Indicates whether Vay.js should ignore vay-* attributes. Default tofalse
.removeAttributesOnRender
(type:boolean
): Determines if translation-related attributes should be removed after rendering. Defaults tofalse
.quiet
(type:boolean
): Controls whether warnings and debug messages are suppressed. Defaults totrue
.defaultLocale
(type:ISO639Code
): Sets the default locale for translations. Defaults to'en'
INFO
The targetAttribute
, ignoreAttributes
& removeAttributesOnRender
properties are only relevant when using a staticProvider
to render a static HTML page.
To customize these settings, use the defineConfig method. This method merges your specified properties with the default configuration, allowing for easy customization:
import { defineConfig } from '@vayjs/vay';
export const config = defineConfig({
defaultLocale: 'es', // Set the default language to Spanish
quiet: false, // Enable console warnings and debug messages
});
// Apply your custom configuration when creating your
// `VayProvider` to integrate these settings into your project:
import { createProvider } from '@vayjs/vay';
import { config } from './i18n.config.ts';
import { dictionaries } from './i18n.dictionaries.ts';
export const i18n = createProvider(myConfig, ...dictionaries);
export const t = i18n.translate;
By adjusting the configuration, you ensure that Vay aligns perfectly with your project's requirements, enhancing the internationalization process.