-
Notifications
You must be signed in to change notification settings - Fork 79
Add FluentResource #244
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
Add FluentResource #244
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good code-wise, but before approving the PR I'd like to learn your opinion on where the parsing logic should live. See #217 (comment) for @Pike's thoughts on this. I think I agree: it would likely make more sense for the parser to be part of FluentResource
. Given that this is supposed to help the Gecko use-case, could you weigh on which approach is the best from the Gecko POV?
fluent/src/context.js
Outdated
@@ -115,22 +131,45 @@ export class MessageContext { | |||
* @returns {Array<Error>} | |||
*/ | |||
addMessages(source) { | |||
const [entries, errors] = parse(source); | |||
for (const id in entries) { | |||
const res = MessageContext.parseResource(source); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use this
here rather than MessageContext
to allow for subclassing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this
throws on babel unfortunately here :(
I'm not strongly opinionated here. Happy to go either way. Eventually there may be some complication when we try to transfer |
Should I move the parser to |
My hope and the intent behind the Once its FTL is parsed, So yeah, let's move parsing to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet, thanks!
This implements the first part of https://bugzilla.mozilla.org/show_bug.cgi?id=1455649 in fluent.js allowing for caching of parsed resources.