Repository navigation
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
Activity
rkh commentedon Feb 12, 2025
Example of what the API could look like:
eemeli commentedon Feb 12, 2025
The library's still maintained, but new feature development is indeed not very active. I'd be very interested in reviewing new PRs, including ones bringing in Temporal support.
rkh commentedon Feb 13, 2025
Pull Request: #635
rkh commentedon Feb 15, 2025
Alternative implementation (more complete Temporal support, but no API for custom values): #636 – happy to integrate this into #635 if that's the preferred approach.
rkh commentedon Mar 24, 2025
@eemeli I assume this can be closed now?
eemeli commentedon Mar 24, 2025
Completed in #636. Release due shortly, once I get some of the dev dependencies refreshed.
Demivan commentedon Nov 16, 2025
@eemeli This breaks type safety of FluentVariable. I have created a PR to fix it #649