Source code
Revision control
Copy as Markdown
Other Tools
# Any copyright is dedicated to the Public Domain.
import re
import fluent.syntax.ast as FTL
from fluent.migrate.transforms import TransformPattern
class STRIP_LABEL(TransformPattern):
# Used to remove `<label data-l10n-name="remove-search-engine-article">` from a string
def visit_TextElement(self, node):
node.value = re.sub(
r'\s?<label data-l10n-name="remove-search-engine-article">.+?</label>\s?',
"",
node.value,
)
return node
def migrate(ctx):
search_ftl = "browser/browser/search.ftl"
ctx.add_transforms(
search_ftl,
search_ftl,
[
FTL.Message(
id=FTL.Identifier("removed-search-engine-message2"),
value=STRIP_LABEL(search_ftl, "removed-search-engine-message"),
),
],
)