summaryrefslogtreecommitdiffstats
path: root/python/l10n/fluent_migrations
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /python/l10n/fluent_migrations
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'python/l10n/fluent_migrations')
-rw-r--r--python/l10n/fluent_migrations/bug_1759175_crashreporter.py127
-rw-r--r--python/l10n/fluent_migrations/bug_1864038_screenshots_migration.py39
-rw-r--r--python/l10n/fluent_migrations/bug_1881582_autocomplete_merge.py63
-rw-r--r--python/l10n/fluent_migrations/bug_1884748_alt_text_images_sync.py24
4 files changed, 253 insertions, 0 deletions
diff --git a/python/l10n/fluent_migrations/bug_1759175_crashreporter.py b/python/l10n/fluent_migrations/bug_1759175_crashreporter.py
new file mode 100644
index 0000000000..245799b426
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1759175_crashreporter.py
@@ -0,0 +1,127 @@
+# 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 transforms_from, VARIABLE_REFERENCE, TERM_REFERENCE
+from fluent.migrate.transforms import (
+ CONCAT,
+ REPLACE,
+ REPLACE_IN_TEXT,
+ LegacySource,
+ Transform,
+)
+
+
+class SPLIT_AND_REPLACE(LegacySource):
+ """Split sentence on '\n\n', return a specific segment, and perform replacements if needed"""
+
+ def __init__(self, path, key, index, replacements=None, **kwargs):
+ super(SPLIT_AND_REPLACE, self).__init__(path, key, **kwargs)
+ self.index = index
+ self.replacements = replacements
+
+ def __call__(self, ctx):
+ element = super(SPLIT_AND_REPLACE, self).__call__(ctx)
+ segments = element.value.split(r"\n\n")
+ element.value = segments[self.index]
+
+ if self.replacements is None:
+ return Transform.pattern_of(element)
+ else:
+ return REPLACE_IN_TEXT(element, self.replacements)(ctx)
+
+
+def migrate(ctx):
+ """Bug 1759175 - Migrate Crash Reporter to Fluent, part {index}."""
+
+ target_file = "toolkit/crashreporter/crashreporter.ftl"
+ source_file = "toolkit/crashreporter/crashreporter.ini"
+
+ ctx.add_transforms(
+ target_file,
+ target_file,
+ transforms_from(
+ """
+crashreporter-title = { COPY(from_path, "CrashReporterTitle") }
+crashreporter-no-run-message = { COPY(from_path, "CrashReporterDefault") }
+crashreporter-button-details = { COPY(from_path, "Details") }
+crashreporter-view-report-title = { COPY(from_path, "ViewReportTitle") }
+crashreporter-comment-prompt = { COPY(from_path, "CommentGrayText") }
+crashreporter-report-info = { COPY(from_path, "ExtraReportInfo") }
+crashreporter-submit-status = { COPY(from_path, "ReportPreSubmit2") }
+crashreporter-submit-in-progress = { COPY(from_path, "ReportDuringSubmit2") }
+crashreporter-submit-success = { COPY(from_path, "ReportSubmitSuccess") }
+crashreporter-submit-failure = { COPY(from_path, "ReportSubmitFailed") }
+crashreporter-resubmit-status = { COPY(from_path, "ReportResubmit") }
+crashreporter-button-ok = { COPY(from_path, "Ok") }
+crashreporter-button-close = { COPY(from_path, "Close") }
+ """,
+ from_path=source_file,
+ ),
+ )
+ ctx.add_transforms(
+ target_file,
+ target_file,
+ [
+ FTL.Message(
+ id=FTL.Identifier("crashreporter-crash-message"),
+ value=SPLIT_AND_REPLACE(
+ source_file,
+ "CrashReporterDescriptionText2",
+ index=0,
+ replacements={
+ "%s": TERM_REFERENCE("brand-short-name"),
+ },
+ ),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("crashreporter-plea"),
+ value=SPLIT_AND_REPLACE(
+ source_file,
+ "CrashReporterDescriptionText2",
+ index=1,
+ ),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("crashreporter-error-details"),
+ value=SPLIT_AND_REPLACE(
+ source_file,
+ "CrashReporterProductErrorText2",
+ index=2,
+ replacements={
+ "%s": VARIABLE_REFERENCE("details"),
+ },
+ ),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("crashreporter-button-quit"),
+ value=REPLACE(
+ source_file,
+ "Quit2",
+ {
+ "%s": TERM_REFERENCE("brand-short-name"),
+ },
+ ),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("crashreporter-button-restart"),
+ value=REPLACE(
+ source_file,
+ "Restart",
+ {
+ "%s": TERM_REFERENCE("brand-short-name"),
+ },
+ ),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("crashreporter-crash-identifier"),
+ value=REPLACE(
+ source_file,
+ "CrashID",
+ {
+ "%s": VARIABLE_REFERENCE("id"),
+ },
+ ),
+ ),
+ ],
+ )
diff --git a/python/l10n/fluent_migrations/bug_1864038_screenshots_migration.py b/python/l10n/fluent_migrations/bug_1864038_screenshots_migration.py
new file mode 100644
index 0000000000..5427a9a848
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1864038_screenshots_migration.py
@@ -0,0 +1,39 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from fluent.migrate.helpers import transforms_from
+
+
+def migrate(ctx):
+ """Bug 1864038 - Consolidate screenshots fluent files, part {index}."""
+
+ source = "browser/browser/screenshotsOverlay.ftl"
+ target = "browser/browser/screenshots.ftl"
+
+ ctx.add_transforms(
+ target,
+ target,
+ transforms_from(
+ """
+screenshots-component-copy-button-label = {COPY_PATTERN(from_path, "screenshots-overlay-copy-button")}
+
+screenshots-component-download-button-label = {COPY_PATTERN(from_path, "screenshots-overlay-download-button")}
+
+screenshots-overlay-selection-region-size-2 = {COPY_PATTERN(from_path, "screenshots-overlay-selection-region-size")}
+""",
+ from_path=source,
+ ),
+ )
+
+ ctx.add_transforms(
+ target,
+ target,
+ transforms_from(
+ """
+screenshots-component-retry-button =
+ .title = {COPY_PATTERN(from_path, "screenshots-retry-button-title.title")}
+ .aria-label = {COPY_PATTERN(from_path, "screenshots-retry-button-title.title")}
+""",
+ from_path=target,
+ ),
+ )
diff --git a/python/l10n/fluent_migrations/bug_1881582_autocomplete_merge.py b/python/l10n/fluent_migrations/bug_1881582_autocomplete_merge.py
new file mode 100644
index 0000000000..3a013cf82b
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1881582_autocomplete_merge.py
@@ -0,0 +1,63 @@
+# 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 VARIABLE_REFERENCE
+from fluent.migrate.transforms import COPY, REPLACE
+
+
+def migrate(ctx):
+ """Bug 1881582 - Merge form autofill autocomplete items into normal autocomplete UI part {index}."""
+
+ propertiesSource = "browser/extensions/formautofill/formautofill.properties"
+ target = "toolkit/toolkit/formautofill/formAutofill.ftl"
+ ctx.add_transforms(
+ target,
+ target,
+ [
+ FTL.Message(
+ id=FTL.Identifier("autofill-clear-form-label"),
+ value=COPY(propertiesSource, "clearFormBtnLabel2"),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-category-address"),
+ value=COPY(propertiesSource, "category.address"),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-category-name"),
+ value=COPY(propertiesSource, "category.name"),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-category-organization"),
+ value=COPY(propertiesSource, "category.organization2"),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-category-tel"),
+ value=COPY(propertiesSource, "category.tel"),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-category-email"),
+ value=COPY(propertiesSource, "category.email"),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-phishing-warningmessage-extracategory"),
+ value=REPLACE(
+ propertiesSource,
+ "phishingWarningMessage",
+ {
+ "%1$S": VARIABLE_REFERENCE("categories"),
+ },
+ ),
+ ),
+ FTL.Message(
+ id=FTL.Identifier("autofill-phishing-warningmessage"),
+ value=REPLACE(
+ propertiesSource,
+ "phishingWarningMessage2",
+ {
+ "%1$S": VARIABLE_REFERENCE("categories"),
+ },
+ ),
+ ),
+ ],
+ )
diff --git a/python/l10n/fluent_migrations/bug_1884748_alt_text_images_sync.py b/python/l10n/fluent_migrations/bug_1884748_alt_text_images_sync.py
new file mode 100644
index 0000000000..924b31c6c1
--- /dev/null
+++ b/python/l10n/fluent_migrations/bug_1884748_alt_text_images_sync.py
@@ -0,0 +1,24 @@
+# Any copyright is dedicated to the Public Domain.
+# http://creativecommons.org/publicdomain/zero/1.0/
+
+from fluent.migrate.helpers import transforms_from
+
+
+def migrate(ctx):
+ """Bug 1884748 - Add alt text to images in about:preferences#sync, part {index}."""
+
+ source = "browser/browser/preferences/preferences.ftl"
+ target = source
+
+ ctx.add_transforms(
+ target,
+ target,
+ transforms_from(
+ """
+sync-profile-picture-with-alt =
+ .tooltiptext = {COPY_PATTERN(from_path, "sync-profile-picture.tooltiptext")}
+ .alt = {COPY_PATTERN(from_path, "sync-profile-picture.tooltiptext")}
+""",
+ from_path=source,
+ ),
+ )