Skip to content

Fluent Syntax 0.8

Pre-release
Pre-release
Compare
Choose a tag to compare
@stasm stasm released this 13 Dec 14:50
  • Preserve content-indent in multiline Patterns. (#162)

    Multiline Patterns require to be indented by at least one space. In
    Syntax 0.7 all leading ident of every line was stripped. In Syntax 0.8
    only the maximum indent common to all indented lines is removed. This
    behavior works for all Patterns: in Messages, Terms, Attributes
    and Variants.

    multiline1 =
        This message has two spaces of indent
          on the second line of its value.

    This behavior also works when the first line of a block Pattern is
    indented relative to the following lines:

    multiline2 =
          This message has two spaces of indent
        on the first line of its value.

    Note that only indented lines participate in this behavior. Specifically,
    if a Pattern starts on the same line as the message identifier, then
    it's not considered as indented, and is excluded from the indent
    stripping.

    multiline3 = This message has two spaces of indent
          on the second line of its value. The first
        line is not considered indented at all.

    If a Pattern starts on the same line as the identifier, its first line
    is subject to the leading-whitespace stripping which is applied to all
    Patterns.

    # Same value as multiline3 above.
    multiline4 =     This message has two spaces of indent
          on the second line of its value. The first
        line is not considered indented at all.

    Note that if a multiline Pattern starts on the same line as the
    identifier and it only consists of one more line of text below it, then
    the maximum indent common to all indented lines is equal to the indent
    of the second line, i.e. the only indented line. All indent will be
    removed in this case. {" "} can be used to preserve it explicitly.

    multiline5 = This message has no indent
            on the second line of its value.
  • Deprecate VariantLists. (#204)

    VariantLists and VariantExpression have been deprecated. They will be
    removed before Fluent 1.0 is released. Please use parameterized Terms
    instead (see below). Furthermore, in Syntax 0.8 it's not possible to nest
    VariantLists anymore (#220).

  • Introduce parameterized Terms. (#176, #212)

    References to Terms can now receive parameters which will be used by
    the runtime as values of variables referenced from within the Term.
    This allows Terms to use regular Patterns as values, rather than
    VariantLists:

    # A Term with a VariantList as a value.
    -thing = {
       *[definite] the thing
        [indefinite] a thing
    }
    
    this = This is { -term[indefinite] }.
    # A parametrized Term with a Pattern as a value.
    -thing = { $article ->
       *[definite] the thing
        [indefinite] a thing
    }
    
    this = This is { -thing(article: "indefinite") }.

    Since Patterns can be nested, this feature allows more complex
    hierarchies of term values:

    # A parametrized Term with nested Patterns.
    -thing = { $article ->
       *[definite] { $first-letter ->
           *[lower] the thing
            [upper] The thing
        }
        [indefinite] { $first-letter ->
           *[lower] a thing
            [upper] A thing
        }
    }
    
    this = This is { -term(first-letter: "lower", article: "indefinite") }.

    Parameters must be named; positional parameters are ignored. If a
    parameter is omitted then the regular default variant logic applies. The
    above example could thus be written as {-term(article: "indefinite")}
    and the lower variant would be used because it is marked as the default
    one. If no parameters are specified, the paranthesis can be omitted:
    {-term()} and {-term} are functionally the same.

    Term attributes can be parameterized as well. To access them, use the
    -term.attr(param: "value") syntax.

  • Support all Unicode characters in values. 🎉 (#174, #207)

    All Unicode characters can now be used in values of TextElements and
    StringLiterals, except those recognized as special by the syntax. Refer
    to spec/recommendations.md for information about character ranges which
    translation authors are encouraged to avoid.

  • Don't store the - sigil in Identifiers of Terms. (#142)

    The - sigil is no longer part of the term's Identifier. This is now
    consistent with how Identifiers of variables don't include the $
    sigil either.

  • Treat backslash (\) as a regular character in TextElements. (#123)

    Backslash does no longer have special escaping powers when used in
    TextElements. It's still recognized as special in StringLiterals,
    however. StringLiterals can be used to insert all special-purpose
    characters in text. For instance, {"{"} will insert the literal opening
    curly brace ({), {"\u00A0"} will insert the non-breaking space, and
    {" "} can be used to make a translation start or end with whitespace,
    which would otherwise by trimmed by Pattern.

  • Forbid closing brace in TextElements. (#186)

    Both the opening and the closing brace are now considered special when
    present in TextElements. {"}"} can be used to insert a literal
    closing brace.

  • Store both the raw and the unescaped value in StringLiteral. (#203)

    StringLiteral.value has been change to store the unescaped ("cooked")
    value of the string literal: all known escape sequences are replaced with
    the characters they represent. StringLiteral.raw has been added and
    stores the raw value as it was typed by the author of the string literal:
    escapes sequences are not processed in any way.

  • Add the \UHHHHHH escape sequence. (#201)

    In addition to the already-supported \uHHHH escape sequence, \UHHHHHH
    is now also recognized and can be used to encode Unicode codepoints in the
    U+010000 to U+10FFFF range. For example, {"\U01F602"} can be used to
    represent 😂.

  • Don't normalize line endings in Junk. (#184)

    Junk represents a literal slice of unparsed content and shouldn't have
    its line endings normalized to LF.

  • Add the FunctionReference production. (#210)

    Function references in CallExpressions are now stored as
    FunctionReference AST nodes, with an id field which is an
    Identifier.

    The Function production and its corresponding AST node have been
    removed. The logic validating that function names are all upper-case has
    been moved to abstract.mjs.