Skip to content

Instantly share code, notes, and snippets.

@KwanEsq
Created March 25, 2019 15:38
Show Gist options
  • Save KwanEsq/2e5bd7ae094130c4403c4b691d6e6502 to your computer and use it in GitHub Desktop.
Save KwanEsq/2e5bd7ae094130c4403c4b691d6e6502 to your computer and use it in GitHub Desktop.
<!ENTITY fill.label "Fill">
fill =
.label =
{ PLATFORM() ->
[linux] Zoom
*[windows] Fill
}
# coding=utf8
from __future__ import absolute_import
import fluent.syntax.ast as FTL
from fluent.migrate.helpers import transforms_from
from fluent.migrate import COPY
def migrate(ctx):
"""Bug 123456 - Blah, part {index}."""
ctx.add_transforms(
"fluent.ftl",
"fluent.ftl",
transforms_from(
"""
fill =
.label = { COPY(from_path, "fill.label") }
""", from_path="entities.dtd")
)
ctx.add_transforms(
"fluent.ftl",
"fluent.ftl",
[
FTL.Message(
id=FTL.Identifier('fill'),
attributes=[
FTL.Attribute(
FTL.Identifier('label'),
FTL.Pattern(
elements=[
FTL.Placeable(
expression=FTL.SelectExpression(
expression=FTL.CallExpression(
callee=FTL.Function('PLATFORM')
),
variants=[
FTL.Variant(
key=FTL.VariantName('linux'),
default=False,
value=''
),
FTL.Variant(
key=FTL.VariantName('windows'),
default=True,
value=COPY(
'entities.dtd',
'fill.label'
)
)
]
)
)
]
)
)
]
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment