MFML - v0.0.4
    Preparing search index...

    Interface CompilerOptions

    Options of createCompiler.

    interface CompilerOptions {
        fallbackLocales?: Record<string, string>;
        getArgumentTSType?: (argumentNode: ArgumentNode) => undefined | string;
        hashLength?: number;
        packageName?: string;
        parser: Parser;
        postprocessors?: Postprocessor[];
        preprocessors?: Preprocessor[];
        renameMessageFunction?: (messageKey: string) => string;
    }
    Index

    Properties

    fallbackLocales?: Record<string, string>

    Mapping from a locale to a corresponding fallback locale.

    For example, let's consider fallbackLocales set to:

    {
    'ru-RU': 'ru',
    'en-US': 'en',
    'ru': 'en'
    }

    In this case:

    • if a message doesn't support ru-RU locale, then compiler would look for ru locale.
    • if ru locale isn't supported as well then a compiler would fall back to en locale.
    • if en isn't supported as well then null would be returned from a message function when called with ru-RU locale.
    getArgumentTSType?: (argumentNode: ArgumentNode) => undefined | string

    Returns the TypeScript type for a given argument.

    argumentNode => {
    if (argumentNode.typeNode?.value === 'number') {
    return 'number|bigint';
    }
    if (argumentNode.typeNode?.value === 'date') {
    return 'number|Date';
    }
    };
    hashLength?: number

    Number of characters in a message body hash.

    8
    
    packageName?: string

    The name of the package from to which compiled messages are written.

    "@mfml/messages"
    
    parser: Parser

    Parser that converts a MFML text message to an MFML AST.

    postprocessors?: Postprocessor[]

    The array of callbacks that are run after the message was parsed as an MFML AST.

    Preprocessors can be used to validate messages, rename arguments, or for other AST-based transformations.

    preprocessors?: Preprocessor[]

    The array of callbacks that are run before message parsing.

    Preprocessors can be used to transform Markdown messages to HTML, or other text-based transformations.

    renameMessageFunction?: (messageKey: string) => string

    Returns the name of a message function for the given message key.