You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: uppercase custom function example per latest messageformat@next (#46)
* Param types fixed (first arg is `context: MessageFunctionContext`, not
`locales: string[]`)
* Return type fixed — only including `toString` doesn't work with
`format` or `formatToParts`
* Use `toLocaleUpperCase` with the locales available in the context,
rather than locale-less `toUpperCase`
It seems like building on top of the built-in `DefaultFunctions.string`
is the simplest way to implement a custom `string -> string` function
that correctly implements the contract expected by `format` and
`formatToParts`. The returned object for input `"{messageformat
:uppercase}"` looks roughly like this:
```ts
{
type: "string",
source: "|messageformat|",
dir: "auto",
selectKey: (keys) => (keys.has(selStr) ? selStr : null),
toParts: () => [{ type: "string", source: "|messageformat|", locale: "en", value: "MESSAGEFORMAT" }],
toString: () => "MESSAGEFORMAT",
valueOf: () => "MESSAGEFORMAT"
}
```
0 commit comments