Source code

Revision control

Copy as Markdown

Other Tools

# Any copyright is dedicated to the Public Domain.
import fluent.syntax.ast as FTL
from fluent.migrate.helpers import VARIABLE_REFERENCE, transforms_from
from fluent.migrate.transforms import COPY, REPLACE
def migrate(ctx):
"""Bug 2073896 - Migrate the Inspector markup view's Paste, Attributes and Break on… submenus to Fluent, part {index}."""
source = "devtools/client/inspector.properties"
target = "devtools/client/inspector.ftl"
ctx.add_transforms(
target,
target,
transforms_from(
"""
markup-context-menu-paste-inner-html =
.label = { COPY(from_path, "inspectorPasteInnerHTML.label") }
.accesskey = { COPY(from_path, "inspectorPasteInnerHTML.accesskey") }
markup-context-menu-paste-outer-html =
.label = { COPY(from_path, "inspectorPasteOuterHTML.label") }
.accesskey = { COPY(from_path, "inspectorPasteOuterHTML.accesskey") }
markup-context-menu-paste-before =
.label = { COPY(from_path, "inspectorHTMLPasteBefore.label") }
.accesskey = { COPY(from_path, "inspectorHTMLPasteBefore.accesskey") }
markup-context-menu-paste-after =
.label = { COPY(from_path, "inspectorHTMLPasteAfter.label") }
.accesskey = { COPY(from_path, "inspectorHTMLPasteAfter.accesskey") }
markup-context-menu-paste-as-first-child =
.label = { COPY(from_path, "inspectorHTMLPasteFirstChild.label") }
.accesskey = { COPY(from_path, "inspectorHTMLPasteFirstChild.accesskey") }
markup-context-menu-paste-as-last-child =
.label = { COPY(from_path, "inspectorHTMLPasteLastChild.label") }
.accesskey = { COPY(from_path, "inspectorHTMLPasteLastChild.accesskey") }
markup-context-menu-add-attribute =
.label = { COPY(from_path, "inspectorAddAttribute.label") }
.accesskey = { COPY(from_path, "inspectorAddAttribute.accesskey") }
markup-context-menu-break-on-subtree-modification =
.label = { COPY(from_path, "inspectorSubtreeModification.label") }
markup-context-menu-break-on-attribute-modification =
.label = { COPY(from_path, "inspectorAttributeModification.label") }
markup-context-menu-break-on-node-removal =
.label = { COPY(from_path, "inspectorNodeRemoval.label") }
""",
from_path=source,
),
)
def message(id, label, accesskey):
return FTL.Message(
id=FTL.Identifier(id),
attributes=[
FTL.Attribute(id=FTL.Identifier("label"), value=label),
FTL.Attribute(id=FTL.Identifier("accesskey"), value=accesskey),
],
)
ctx.add_transforms(
target,
target,
[
message(
"markup-context-menu-copy-attribute-value",
REPLACE(
source,
"inspectorCopyAttributeValue.label",
{"%1$S": VARIABLE_REFERENCE("value")},
),
COPY(source, "inspectorCopyAttributeValue.accesskey"),
),
message(
"markup-context-menu-edit-attribute",
REPLACE(
source,
"inspectorEditAttribute.label",
{"%1$S": VARIABLE_REFERENCE("name")},
),
COPY(source, "inspectorEditAttribute.accesskey"),
),
message(
"markup-context-menu-remove-attribute",
REPLACE(
source,
"inspectorRemoveAttribute.label",
{"%1$S": VARIABLE_REFERENCE("name")},
),
COPY(source, "inspectorRemoveAttribute.accesskey"),
),
],
)