Configuration
psitta function
Initializes the global Psitta configuration.
Signature
typescriptfunction psitta(options: Partial<Config>): Config
Parameters
options
: Optional object containing partial configuration overrides.
Returns
The complete Psitta configuration object.
Details
If no global Psitta configuration exists yet,
psitta
will create one using the default configuration values. Typically, you provide an optionaloptions
object to merge additional configuration settings on top of the existing or default configuration. This allows for customization without overwriting the entire configuration.Examples
typescriptconst messages = { 'Welcome!': { pt: 'Seja bem-vind{g} (o|a)', }, } as const; psitta({ locales: ['en', 'pt'], // Define supported locales messages, // Provide translations for messages });
getConfig function
Gets the Psitta configuration object, merging defaults, global options, and provided options.
Signature
typescriptfunction getConfig(options: Partial<Config>): Config
Parameters
options
: Optional object containing partial configuration overrides.
Returns
The complete Psitta configuration object.
Examples
typescript// Get the default configuration const defaultConfig = getConfig(); console.log(defaultConfig); // Output: Contains default i18n configuration values // Override some options with custom ones const customConfig = getConfig({ locale: 'fr', // Set custom locale }); console.log(customConfig); // Output: Merged configuration with custom options