Skip to content

Conversation

@stasm
Copy link
Contributor

@stasm stasm commented May 9, 2017

This is a rebase of l20n/python-l20n#5 and its follow-ups (l20n/python-l20n#10, l20n/python-l20n#11 as well as changes in @Pike's branch, adjusted to the changes in the Fluent syntax and AST:

  • Placeables are no longer lists.
  • ExternalArgument takes an Identifier instance
  • Traits are gone, replaced by attributes.
  • Member is gone, replaced by Variant or Attribute.
  • Keyword is gone, replace by Symbol.
  • Sections are flat.

Since it already got an r+ back in the day, I'm mostly interested in the review of the first two commits.

My next steps are:

@stasm
Copy link
Contributor Author

stasm commented May 12, 2017

I'll port the first two commits to fluent.js when this lands.


# All section headers will be merged.
if isinstance(entry, FTL.Section):
return entry
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This unconditionally merges all Sections into the final result. Note that this mean only the section header, not the messages below it. We might consider only merging a section if at least one message under it is also being merged.

return LITERAL(source)(ctx)


class EXTERNAL(Transform):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm considering a number of renames for the transforms, which I'll propose in a follow-up PR. Originally, all transforms except for SOURCE return a Pattern which makes them suitable for using as values of messages. Also CONCAT is implemented such that it can unwrap the expression from the Pattern and fold more than one transform into a single Pattern.

With a simple change to CONCAT it should be possible to do the same conditionally: i.e. unwrap Patterns when needed while keeping normal expressions unchanged. I think we'll end up with EXTERNAL_EXPR for selectors and replacements and LITERAL_PATTERN, PLURAL_PATTERN and CONCAT_PATTERNS for dealing with patterns.

@stasm stasm merged commit 01998d8 into projectfluent:master May 15, 2017
@stasm stasm deleted the migrate branch May 15, 2017 22:22
Copy link
Contributor

@Pike Pike left a comment

Choose a reason for hiding this comment

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

I didn't find a chance to actually spend time on this, submitting my one comment that I had so far

if timestamp < changeset['first_commit']:
changeset['first_commit'] = timestamp

return sorted(changesets, key=by_first_commit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we want to call this in more places, I'd just inline this as a lambda function.

If you'd like to keep the method, please adjust that the doc string to denote it as a thing used by sort, not sorting itself?

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.

3 participants