-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
Clear and concise description of the problem
It would be nice if there was a way to support more variable types than numbers, strings, and Date instances.
Things that come to mind are Temporal objects or Vue references.
Suggested solution
Support passing in a configuration option to map variable values to FluentType instance. This could be done as a function, or an object mapping, or something else.
Example:
const fluent = createFluentVue({
wrapVariable(value: Temporal.ZonedDateTime | FluentVariable): FluentVariable {
if(value instanceof Temporal.ZonedDateTime) {
return new FluentDateTime(value.epochMilliseconds, { timeZone: value.timeZoneId })
} else {
return value
}
}
})
Alternative
A few alternatives:
- Implement this functionality in fluent-bundle itself, then support the API addition here. My main concern would be getting it implemented, merged, released, and then integrated here in any reasonable timeframe. This could be combined with other solutions, though – first implement something with the current fluent-bundle, then move to using the new API once it has been released. See Additional variable types / Temproal support projectfluent/fluent.js#634
- Wrapping the
FluentBundle
instances passed tocreateFluentVue
– this was my first idea, but didn't work becauseinheritBundle
would drop any wrapper. - Override properties and directives defined by
createFluentVue
. - No support. Will have to manually wrap Temporal instances and other objects before any call to
$t
or similar.
Additional context
Happy to work on a pull request.
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
No labels