Skip to content

Variable casting and Temporal support #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

rkh
Copy link
Contributor

@rkh rkh commented Feb 13, 2025

Implements #634

Variable casting

Went for a slightly different API than in the issue.

bundle = new FluentBundle("en-US")

// these aren't needed, as they come built-in, but to illustrate the new API
bundle.addCast("number", FluentNumber)
bundle.addCast(Date, (value: Date) => new FluentDateTime(value.getTime()));

Temporal support

I've put this in a separate package for now, as Temporal is still considered experimental.

It also currently only supports Instant and ZonedDateTime.

Best illustration is probably bundle_test.js.

"license": "Apache-2.0",
"contributors": [
{
"name": "Konstantin Haase",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put myself in here. You can take me out, though. I'm happy to "gift" this little library to Mozilla.

@rkh
Copy link
Contributor Author

rkh commented Feb 14, 2025

I am happy to work on the remaining Temporal classes, especially Duration.

We are working on a production app (pre-alpha atm) where we use a Temporal polyfill and Fluent, and we're expecting to use almost all Temporal classes eventually, so I'm also happy to keep an eye on any bugs etc that pop up in the future.

@rkh rkh mentioned this pull request Feb 15, 2025
@eemeli
Copy link
Member

eemeli commented Feb 17, 2025

I think this level of generalisation is a bit too much, and we should just add Temporal support as in #636.

If there is a real need for something like this later on, it would be best to package the functionality within FluentNumber, FluentDateTime, and related classes.

@eemeli eemeli closed this Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants