Skip to content

Additional variable types / Temproal support #634

Closed
@rkh

Description

@rkh

Currently, fluent-bundle cannot handle Temporal.

What would need to change

It is hardcoded only to support FluentVariable entries (FluentType, string, number, or Date).

Here's how they are resolved:

// Return early if the argument already is an instance of FluentType.
if (arg instanceof FluentType) {
return arg;
}
// Convert the argument to a Fluent type.
switch (typeof arg) {
case "string":
return arg;
case "number":
return new FluentNumber(arg);
case "object":
if (arg instanceof Date) {
return new FluentDateTime(arg.getTime());
}
// eslint-disable-next-line no-fallthrough
default:
scope.reportError(
new TypeError(`Variable type not supported: $${name}, ${typeof arg}`)
);
return new FluentNone(`$${name}`);
}
}

It is, therefore, not possible to pass in other values.

Possible fixes

  • Built-in support for Temporal objects
  • A way to pass in a function to convert custom objects into FluentType instances
  • All of the above

The first one would be very convenient but would also require checking whether Temporal exists.

Project status

As a side note, I'm seeing a lot of old issues with no progress. I'm happy to work on a PR for this, but I'm wondering what the maintenance status of the project is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions