@messageformat/fluent
Version:
Conversion & compatibility tools for using Fluent with MessageFormat 2
39 lines (38 loc) • 1.97 kB
TypeScript
import * as Fluent from '@fluent/syntax';
import { MessageFormatOptions } from 'messageformat';
import type { FluentMessageResource, FluentMessageResourceData } from './index.ts';
/**
* Compile a Fluent resource (i.e. an FTL file) into a Map of
* {@link MessageFormat} instances.
*
* Uses {@link DraftFunctions.currency}, {@link DraftFunctions.unit}, as well as
* a custom `fluent:message` function provided by {@link getMessageFunction}.
*
* @param source - A Fluent resource,
* as the string contents of an FTL file,
* as a {@link https://projectfluent.org/fluent.js/syntax/classes/resource.html | Fluent.Resource},
* or in the shape output by {@link fluentToResourceData} as `data`.
* @param locales - The locale code or codes to use for all of the resource's messages.
* @param options - The MessageFormat constructor options to use for all of the resource's messages.
* @param options.detectNumberSelection - Set `false` to disable number selector detection based on keys.
*/
export declare function fluentToResource(locales: string | string[] | undefined, source: string | Fluent.Resource | FluentMessageResourceData, options?: MessageFormatOptions & {
detectNumberSelection?: boolean;
}): FluentMessageResource;
/**
* Compile a Fluent resource (i.e. an FTL file) into a Map of
* {@link MF.Message | Model.Message} data objects.
*
* @param source - A Fluent resource,
* as the string contents of an FTL file or
* as a {@link https://projectfluent.org/fluent.js/syntax/classes/resource.html | Fluent.Resource}
* @param options.detectNumberSelection - Set `false` to disable number selector detection based on keys.
* @returns An object containing the messages as `data` and any resource-level
* `comments` of the resource.
*/
export declare function fluentToResourceData(source: string | Fluent.Resource, options?: {
detectNumberSelection?: boolean;
}): {
data: FluentMessageResourceData;
comments: string;
};