fluent.js
fluent.js copied to clipboard
@fluent/bundle how to use FluentType.toString
Recently Scope
was introduced which is now needed to use FluentType.toString
. However, Scope
is currently not exported. So how can we use toString
from outside the library without having access to Scope
?
What is your the use-case?
We're exposing FluentType
so that you can use them to pass "tainted" variables into Fluent, that is, hints about date and number formatting to use in formatPattern
in the end.
Right now I don't have a special use case. I am just wondering whether toString
belongs to the public api, and if so, one should be able to use it.
I don't consider Scope
to be part of our public API right now.
There's a question of opinion on toString()
being part of the public API of any JS object. I wonder what to do about that. I'll leave this open for that. We're probably not going to make changes to this before November.
A potential solution could be allowing to pass a Bundle
or a Scope
. If its a Bundle
then inside toString
a Scope
could easily be created.
Let's revisit the parameters to toString
when we work on #383. The parts yielded from formatToParts
would likely need to be toString
'ed, which might mean it would be better to pass a Bundle
instance rather than Scope
, as you mention. This might also impact how we report errors from formatters.