Skip to content

FluentBundle.format() should accept a string identifier of a message or a path to an attribute #208

Closed
@stasm

Description

@stasm

If #205 lands, we could change MessageContext.format() to accept an identifier of a message and format it directly to string. It would avoid the intermediate step of having to first getMessage the message from the context, which is a bit clunky and is an artifact of how the bindings retrieve translated attributes.

// BEFORE
let message = ctx.getMessage("message-key");
let translation = ctx.format(msg, args);
// AFTER
let translation = ctx.format("message-key", args);

For attributes, we could introduce the following syntax:

// AFTER
let translation = ctx.format("message-key.attr-name", args);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions