Skip to content
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

Expose FluentSerializer.serializeExpression #134

Merged
merged 1 commit into from
Jan 24, 2018

Conversation

stasm
Copy link
Contributor

@stasm stasm commented Jan 24, 2018

@mathjazz wrote the following snippet for Pontoon and asked if we could expose it from fluent-syntax.

https://gist.github.com/mathjazz/4be883ea2562e2cbb59ca26beecf1e93

Yes, yes we could.

@stasm stasm force-pushed the expose-serializeExpression branch from be7ff8f to 0dbdc3a Compare January 24, 2018 14:34
@stasm stasm requested a review from mathjazz January 24, 2018 14:39
@stasm
Copy link
Contributor Author

stasm commented Jan 24, 2018

@mathjazz This exposes the serializeExpression method on instances of the FluentSerializer class. Let me know if this works for your use-case.

// A select expression with a selector.
? `{ ${serializeSelectExpression(expr)}}`
// A variant list without a selector.
: `{${serializeSelectExpression(expr)}}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we use a single space before and after the expression?

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 is special-cased so that there aren't any spaces around it. Consider:

-brand-name =
    {    ← no space after the opening {
       *[nominative] Firefox
    }    ← no extra space before the closing {, just the 4-space indent

Copy link

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Fan @stas tic!

I hacked this into the currently used fluent-syntax.js in Pontoon and it does the job.

@stasm stasm requested a review from zbraniecki January 24, 2018 18:35
@stasm stasm merged commit 4614620 into projectfluent:master Jan 24, 2018
@stasm stasm deleted the expose-serializeExpression branch January 24, 2018 18:56
stasm added a commit to projectfluent/python-fluent that referenced this pull request Jan 29, 2018
stasm added a commit that referenced this pull request Jan 31, 2018
  - Implement Fluent Syntax 0.5.

    - Add support for terms.
    - Add support for `#`, `##` and `###` comments.
    - Remove support for tags.
    - Add support for `=` after the identifier in message and term
      defintions.
    - Forbid newlines in string expressions.
    - Allow trailing comma in call expression argument lists.

    In fluent-syntax 0.6.x the new Syntax 0.5 is supported alongside the old
    Syntax 0.4. This should make migrations easier.

    `FluentParser` will correctly parse Syntax 0.4 comments (prefixed with
    `//`), sections and message definitions without the `=` after the
    identifier. The one exception are tags which are no longer supported.
    Please use attributed defined on terms instead.

    `FluentSerializer` always serializes using the new Syntax 0.5.

  - Add `AST.Placeable` (#64)

    Added in Syntax Spec 0.4, `AST.Placeable` provides exact span data about
    the opening and closing brace of placeables.

  - Expose `FluentSerializer.serializeExpression`. (#134)

  - Serialize standalone comments with surrounding white-space.

  - Allow blank lines inside of messages. (#76)

  - Trim trailing newline from Comments. (#77)
eemeli pushed a commit to mozilla/fluent-migrate that referenced this pull request May 16, 2023
jfx2006 pushed a commit to jfx2006/tb-fluent-migrate that referenced this pull request Jul 27, 2023
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