summaryrefslogtreecommitdiffstats
path: root/python/l10n/fluent_migrations/bug_1832186_popupwarning.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/l10n/fluent_migrations/bug_1832186_popupwarning.py')
-rw-r--r--python/l10n/fluent_migrations/bug_1832186_popupwarning.py139
1 files changed, 139 insertions, 0 deletions
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("”"),
+ },
+ ),
+ )
+ ],
+ ),
+ ],
+ )