- Drop support for Python 2.7 and 3.5 & support for Python 3.6 through 3.9 (#161)
- Treat tab as text, not whitespace (#179)
- Add type hints (#180)
-
Fix serialization of multiline patterns starting with special characters. (#156)
The built-in behavior of
FluentSerializer
is to serialize multiline patterns starting on a new line:key = Foo Bar
This used to lead to syntax errors if the pattern started with one of the special characters in the Fluent Syntax: a curly brace, a period, an asterisk, or a square bracket, and if it was originally written with the first line on the same line as the identifier:
key = *Foo Bar
Such a pattern must not be serialized as following, because the asterisk has a special meaning if placed at the beginning of a line.
# Syntax Error key = *Foo Bar
The fix preserves the original layout of the pattern, i.e. it is now serialized starting inline with the identifier.
- Documentation is now on https://projectfluent.org/python-fluent/fluent.syntax/.
- Removal of deprecated
BaseNode.traverse
method. - Refactor
Visitor
andTransformer
intofluent.syntax.visitor
(from.ast
)
-
Parser fix for whitespace before call arguments.
This includes the fixes for projectfluent/fluent#281.
-
Parser fix for selector expressions being too lenient.
This includes the fixes for projectfluent/fluent#279.
-
Comment Serializer fix.
The serializer had a bug when asked to serialize empty comments.
-
Support Fluent Syntax 1.0.
Fluent Syntax 1.0 has been published today. There are no changes to the grammar nor the AST compared to the Syntax 0.9.
This release of fluent.syntax
brings support for version 0.9 of the Fluent
Syntax spec. The API remains unchanged. Files written in valid Syntax 0.8 may
parse differently in this release. See the compatibility note below. Consult
the full Syntax 0.9 changelog for details.
-
Flatten complex reference expressions.
Reference expressions which may take complex forms, such as a reference to a message's attribute, or a parameterized reference to an attribute of a term, are now stored in a simplified manner. Instead of nesting multiple expression nodes (e.g.
CallExpression
of anAttributeExpression
of aTermReference
), all information is available directly in the reference expression.This change affects the following AST nodes:
MessageReference
now has an optionalattribute
field,FunctionReference
now has a requiredarguments
field,TermReference
now has an optionalattribute
field and an optionalarguments
field.
-
Remove
VariantLists
.The
VariantLists
and theVariantExpression
syntax and AST nodes were deprecated in Syntax 0.9 and have now been removed. -
Rename
StringLiteral.raw
tovalue
.StringLiteral.value
contains the exact contents of the string literal, character-for-character. Escape sequences are stored verbatim without processing. A new method,Literal.parse
, can be used to process the raw value of the literal into an unescaped form. -
Rename
args
toarguments
.The
args
field ofMessageReference
,TermReference
,FunctionReference
, andAnnotation
has been renamed toarguments
.
-
Make
BaseNode.equals
stricter when comparing lists.Starting from this version,
BaseNode.equals
now takes the order of variants and attributes into account when comparing two nodes. -
Remove
FluentSerializer.serialize_expression
.The stateless equivalent can still be imported from
fluent.syntax.serializer
:from fluent.syntax.serializer import serialize_expression
-
Fixes to the
Visitor
APIThe
Visitor
API introduced in 0.11 was changed to align more with what Python'sast.Visitor
does. This also allows implementations to have code after descending into child nodes.
-
API enhancements
There are two new APIs in
fluent.syntax.ast
,Visitor
andTransformer
. Use these APIs for read-only iteration over AST trees, and in-place mutation of AST trees, respectively. There's also a new methodBaseNode.clone
, which can be used to create a deep copy of an AST node. -
DEPRECATIONS
The API
BaseNode.traverse
is deprecated and will be removed in a future release. Please adjust your code to theVisitor
orTransformer
APIs.
The fluent
package which used to provide the fluent.syntax
module has been
renamed to fluent.syntax
on PyPI. The code is identical to fluent
0.10.
This release brings support for version 0.8 of the Fluent Syntax spec. The API remains unchanged. Files written in valid Syntax 0.7 may not parse correctly in this release. See the summary of backwards-incompatible changes below.
-
Implement Fluent Syntax 0.8. (#303)
This is only a quick summary of the spec changes in Syntax 0.8. Consult the full changelog for details.
In multiline
Patterns
, all common indent is now removed from each indented line in the final value of the pattern.multiline = This message has 2 spaces of indent on the second line of its value.
Terms
can now be parameterized via the call expression syntax.# A parametrized Term with a Pattern as a value. -thing = { $article -> *[definite] the thing [indefinite] a thing } this = This is { -thing(article: "indefinite") }.
VariantLists
are now deprecated and will be removed from the Syntax before version 1.0.All escapes sequences can only be used in
StringLiterals
now (see below).\UHHHHHH
is a new escape sequence format suitable for codepoints above U+FFFF, e.g.{"\U01F602"}
.
- The backslash character (
\
) is now considered a regular character inTextElements
. It's no longer possible to use escape sequences inTextElements
. Please useStringLiterals
instead, e.g.{"\u00A0"}
. - The closing curly brace character (
}
) is not allowed inTextElements
now. Please useStringLiterals
instead:{"}"}
. StringLiteral.value
was changed to store the unescaped ("cooked") value.StringLiteral.raw
has been added to store the raw value.- The AST of
CallExpressions
was changed to better accommodate the introduction of parameterizedTerms
. TheFunction
AST node has been replaced by theFunctionReference
node. - The leading dash (
-
) is no longer part of theIdentifier
node inTerms
andTermReferences
.
This release brings support for version 0.7 of the Fluent Syntax spec. The API remains unchanged. Files written in valid Syntax 0.6 may not parse correctly in this release. See the summary of backwards-incompatible changes below.
-
Implement Fluent Syntax 0.7. (#287)
The major new feature of Syntax 0.7 is the relaxation of the indentation requirement for all non-text elements of patterns. It's finally possible to leave the closing brace of select expressions unindented:
emails = { $unread_email_count -> [one] You have one unread email. *[other] You have { $unread_email_count } unread emails. }
Consult the changelog to learn about other changes in Syntax 0.7.
- Variant keys can now be either
NumberLiterals
(as previously) orIdentifiers
. TheVariantName
node class has been removed. Variant keys with spaces in them produce syntax errors, e.g.[New York]
. CR
is not a valid EOL character anymore. Please useLF
orCRLF
.Tab
is not recognized as syntax whitespace. It can only be used in translation content.
-
Implement support for Fluent Syntax 0.6. (#69)
Syntax 0.6 keeps the syntax unchanged but makes many changes to the AST. Consult https://github.com/projectfluent/fluent/releases/tag/v0.6.0 for the list of changes.
-
Remove
fluent.migrate
.The migration code has been moved into its own repository: fluent-migration. See bug 1445881 for more information about the move.
-
Add the
ref
field toVariantExpression
. (#62)The
Identifier
-typedid
field has been removed. The newref
field contains theMessageReference
node rigt now. The range of valid expressions forref
may be extended in the future. -
Fix missing
Spans
onFunction
nodes.
- use compare-locales for plurals ordering (bug 1415844)
- create transforms when all dependencies have been met up to a changeset
- support variant keys in BaseNode.equals
- serialize select expressions on a new line
- Fix merge code to handle Terms properly
-
Inline Patterns may start with any character. (#48)
}
,.
,*
and[
are only special when they appear at the beginning of indented Pattern lines. When a Pattern starts on the same line asid =
or[variant key]
, its first character doesn't carry any special meaning and it may be one of those four ones as well.This also fixes a regression from 0.6.0 where a message at the EOF without value nor attributes was incorrectly parsed as a message with an empty Pattern rather than produce a syntax error.
-
Require compare-locales to run and test fluent.migrate. (#47)
Various fixes to fluent.migrate
for bug 1424682.
-
Accept
Patterns
andPatternElements
inREPLACE
. (#41)REPLACE
can now usePatterns
,PatternElements
andExpressions
as replacement values. This makesREPLACE
accept the same Transforms asCONCAT
. -
Never migrate partial translations. (#44)
Partial translations may break the AST because they produce
TextElements
withNone
values. For now, we explicitly skip any transforms which depend on at least one missing legacy string to avoid serialization errors. -
Warn about unknown FTL entries in transforms. (#40)
-
Fix how files are passed to
hg annotate
. (#39)
-
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. -
Expose
FluentSerializer.serializeExpression
. (#134) -
Fix Bug 1428000 - Migrate: only annotate affected files (#34)
-
Run Structure and Behavior tests in Python 3 (#22)
-
Bug 1411943 - Fix Blame for Mercurial 4.3+ (#23)
-
Bug 1412808 - Remove the LITERAL helper. (#25)
-
Bug 1321279 - Read target FTL files before migrations. (#24)
The reference file for the transforms must now be passed as the second argument to add_transforms.
-
Bug 1318960 - Migrate files only when their messages change (#26)
-
Bug 1366298 - Skip SelectExpression in PLURALS for one plural category (#27)
-
Bug 1321290 - Migrate HTML entities to Unicode characters (#28)
-
Bug 1420225 - Read legacy files when scanning for Sources in transforms (#30)
MergeContext.maybe_add_localization is now automaatically called interally when the context encounters a transforms which is a subclass of Source.
- Bug 1397234 - Allow blank lines before attributes, tags and multiline patterns
- Bug 1406342 - Trim trailing newline in Comment and Section spans
-
Add an intermediate Placeable node for Expressions within Patterns.
This allows storing more precise information about the whitespace around the placeable's braces.
-
Serializer: Add newlines around standalone comments.
-
Add BaseNode.equals for deep-equality testing.
Nodes are deeply compared on a field by field basis. If possible, False is returned early. When comparing attributes, tags and variants in SelectExpressions, the order doesn't matter. By default, spans are not taken into account. Other fields may also be ignored if necessary:
message1.equals(message2, ignored_fields=['comment', 'span'])
- This is the first release to be listed in the CHANGELOG.