-
Notifications
You must be signed in to change notification settings - Fork 81
Closed
Description
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:
fluent.js/fluent-bundle/src/resolver.ts
Lines 178 to 200 in 48e2a62
// 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
Labels
No labels