Skip to content

Commit

Permalink
Wrap MessageFunction source, locales args in one object, adding dir (#38
Browse files Browse the repository at this point in the history
)
  • Loading branch information
eemeli authored Jan 8, 2024
1 parent 0e2e2e7 commit 1243189
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,22 @@ to complement or replace the default ones.

```ts
type MessageFunction = (
source: string,
locales: string[],
msgCtx: MessageFunctionContext,
options: { [key: string]: unknown },
input?: unknown
) => MessageValue;

interface MessageFunctionContext {
locales: string[];
dir: 'ltr' | 'rtl' | 'auto';
source: string;
}
```

The `msgCtx` value defines the context in which the expression is being resolved,
with the `locales` and `dir` of the whole message
as well as the `source` fallback string representation of the expression.

The `input` and `options` values are constructed as follows:

- If the value is a literal defined in the message syntax,
Expand Down

0 comments on commit 1243189

Please sign in to comment.