From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../fluent_migrations/bug_1832186_popupwarning.py | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 python/l10n/fluent_migrations/bug_1832186_popupwarning.py (limited to 'python/l10n/fluent_migrations/bug_1832186_popupwarning.py') diff --git a/python/l10n/fluent_migrations/bug_1832186_popupwarning.py b/python/l10n/fluent_migrations/bug_1832186_popupwarning.py new file mode 100644 index 0000000000..4239899725 --- /dev/null +++ b/python/l10n/fluent_migrations/bug_1832186_popupwarning.py @@ -0,0 +1,139 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +import fluent.syntax.ast as FTL +from fluent.migrate.helpers import TERM_REFERENCE, VARIABLE_REFERENCE +from fluent.migrate.transforms import ( + COPY, + PLURALS, + REPLACE, + REPLACE_IN_TEXT, +) + + +def migrate(ctx): + """Bug 1832186 - Migrate popup warning strings to Fluent, part {index}.""" + + source = "browser/chrome/browser/browser.properties" + target = "browser/browser/browser.ftl" + + ctx.add_transforms( + target, + target, + [ + FTL.Message( + id=FTL.Identifier("popup-warning-message"), + value=PLURALS( + source, + "popupWarning.message", + VARIABLE_REFERENCE("popupCount"), + foreach=lambda n: REPLACE_IN_TEXT( + n, + { + "#1": TERM_REFERENCE("brand-short-name"), + "#2": VARIABLE_REFERENCE("popupCount"), + }, + ), + ), + ), + FTL.Message( + id=FTL.Identifier("popup-warning-exceeded-message"), + value=PLURALS( + source, + "popupWarning.exceeded.message", + VARIABLE_REFERENCE("popupCount"), + foreach=lambda n: REPLACE_IN_TEXT( + n, + { + "#1": TERM_REFERENCE("brand-short-name"), + "#2": VARIABLE_REFERENCE("popupCount"), + }, + ), + ), + ), + FTL.Message( + id=FTL.Identifier("popup-warning-button"), + attributes=[ + FTL.Attribute( + id=FTL.Identifier("label"), + value=FTL.Pattern( + [ + FTL.Placeable( + FTL.SelectExpression( + selector=FTL.FunctionReference( + FTL.Identifier("PLATFORM"), + FTL.CallArguments(), + ), + variants=[ + FTL.Variant( + key=FTL.Identifier("windows"), + value=COPY( + source, "popupWarningButton" + ), + ), + FTL.Variant( + key=FTL.Identifier("other"), + value=COPY( + source, "popupWarningButtonUnix" + ), + default=True, + ), + ], + ) + ) + ] + ), + ), + FTL.Attribute( + id=FTL.Identifier("accesskey"), + value=FTL.Pattern( + [ + FTL.Placeable( + FTL.SelectExpression( + selector=FTL.FunctionReference( + FTL.Identifier("PLATFORM"), + FTL.CallArguments(), + ), + variants=[ + FTL.Variant( + key=FTL.Identifier("windows"), + value=COPY( + source, + "popupWarningButton.accesskey", + ), + ), + FTL.Variant( + key=FTL.Identifier("other"), + value=COPY( + source, + "popupWarningButtonUnix.accesskey", + ), + default=True, + ), + ], + ) + ) + ] + ), + ), + ], + ), + FTL.Message( + id=FTL.Identifier("popup-show-popup-menuitem"), + attributes=[ + FTL.Attribute( + id=FTL.Identifier("label"), + value=REPLACE( + source, + "popupShowPopupPrefix", + { + "%1$S": VARIABLE_REFERENCE("popupURI"), + "‘": FTL.TextElement("“"), + "’": FTL.TextElement("”"), + }, + ), + ) + ], + ), + ], + ) -- cgit v1.2.3