MFML - v0.0.4
    Preparing search index...

    Interface Config

    The user-facing compilation config.

    interface Config {
        decodeText?: (text: string) => string;
        fallbackLocales?: Record<string, string>;
        getArgumentTSType?: (argumentNode: ArgumentNode) => undefined | string;
        hashLength?: number;
        messages: { [locale: string]: { [messageKey: string]: string } };
        outDir?: string;
        packageName?: string;
        postprocessors?: Postprocessor[];
        preprocessors?: Preprocessor[];
        renameMessageFunction?: (messageKey: string) => string;
        tokenizerOptions?: TokenizerOptions;
    }

    Hierarchy

    Index

    Properties

    decodeText?: (text: string) => string

    Decode text content before it is pushed to an MFML AST node. Use this method to decode HTML entities.

    Type Declaration

      • (text: string): string
      • Parameters

        • text: string

          Text to decode.

        Returns string

    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
    
    messages: { [locale: string]: { [messageKey: string]: string } }

    Messages arranged by a locale.

    outDir?: string

    The directory that contains node_modules.

    "."
    
    packageName?: string

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

    "@mfml/messages"
    
    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.

    tokenizerOptions?: TokenizerOptions

    Options that define how input text MFML messages are tokenized.

    By default, forgiving HTML tokenizer options are used.