Store unescaped content in StringLiteral.value and raw content in StringLiteral.raw by stasm · Pull Request #203 · projectfluent/fluent · GitHub
Skip to content

Store unescaped content in StringLiteral.value and raw content in StringLiteral.raw#203

Merged
stasm merged 4 commits into
projectfluent:masterfrom
stasm:raw
Nov 8, 2018
Merged

Store unescaped content in StringLiteral.value and raw content in StringLiteral.raw#203
stasm merged 4 commits into
projectfluent:masterfrom
stasm:raw

Conversation

@stasm

@stasm stasm commented Nov 6, 2018

Copy link
Copy Markdown
Contributor

This also forbids escape sequences representing surrogate code points, following @Pike's suggestion from #194 (comment). If we allow them, then their handling becomes environment/implementation dependent. E.g. they are ill-formed in the UTF-8 encoding.

@Pike Pike left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm using .val and .raw_val in compare-locales, and I'm very unhappy about that. Just yesterday had to change one for the other, because the difference isn't obvious.

That said, maybe that's OK within this context, but we'll need comments for that.

Also, please keep the current semantics of .value, as most tools use that and will want to continue to use that.
How about .format_value or .bundle_value for the unescaped value? That indicates the API in which to use that variant?

@stasm

stasm commented Nov 6, 2018

Copy link
Copy Markdown
Contributor Author

@Pike

Pike commented Nov 6, 2018

Copy link
Copy Markdown
Contributor

Where would you put it?

In ast.mjs, so that consumers of that API know what to use when.

@stasm stasm requested a review from Pike November 6, 2018 13:35
@Pike

Pike commented Nov 8, 2018

Copy link
Copy Markdown
Contributor

This is technically OK, but I disagree with the choice out of my own experience in compare-locales.

Practically, this is going to add a significant risk in particular to the Pontoon support, as we're changing the data the existing .value API returns.

Not going to block this, but also not going to r+ this, so removing myself from the review.

@Pike Pike removed their request for review November 8, 2018 10:47
@Pike

Pike commented Nov 8, 2018

Copy link
Copy Markdown
Contributor

Meh, can't find a way to actually remove myself without showing my previous r-.

@stasm

stasm commented Nov 8, 2018

Copy link
Copy Markdown
Contributor Author

Practically, this is going to add a significant risk in particular to the Pontoon support, as we're changing the data the existing .value API returns.

Thank you for you comment. I think I'm misunderstanding something here. When we update Pontoon to Syntax 0.8, we'll change the code which deals with StringLiterals to use the .raw field rather than .value. It sounds like this will solve this problem completely. We'll need to make changes to tools anyways. Is there more to this which I'm not seeing?

@stasm

stasm commented Nov 8, 2018

Copy link
Copy Markdown
Contributor Author

Actually, it looks like updating the serializer to use .raw for StringLiterals (which we'll need to do anyways) will be enough for Pontoon: https://github.com/mozilla/pontoon/blob/d55d260554d13173e4ee39629becbd0ab3a264af/pontoon/base/static/js/fluent_interface.js#L435.

@Pike

Pike commented Nov 8, 2018

Copy link
Copy Markdown
Contributor

My point is that I made the same exact API decision, and it's been a source of bugs (just this week, actually).

That said, I don't want to spend more time on this ticket.

@stasm

stasm commented Nov 8, 2018

Copy link
Copy Markdown
Contributor Author

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