# 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, transforms_from, ) from fluent.migrate.transforms import REPLACE def migrate(ctx): """Bug 2101372 - Migrate permission prompt strings from browser.properties to Fluent, part {index}.""" source = "browser/chrome/browser/browser.properties" target = "browser/browser/permissions.ftl" ctx.add_transforms( target, target, transforms_from( """ perm-geolocation-allow = .label = { COPY(from_path, "geolocation.allow") } .accesskey = { COPY(from_path, "geolocation.allow.accesskey") } perm-geolocation-block = .label = { COPY(from_path, "geolocation.block") } .accesskey = { COPY(from_path, "geolocation.block.accesskey") } perm-xr-allow = .label = { COPY(from_path, "xr.allow2") } .accesskey = { COPY(from_path, "xr.allow2.accesskey") } perm-xr-block = .label = { COPY(from_path, "xr.block") } .accesskey = { COPY(from_path, "xr.block.accesskey") } perm-persistent-storage-allow = .label = { COPY(from_path, "persistentStorage.allow") } .accesskey = { COPY(from_path, "persistentStorage.allow.accesskey") } perm-persistent-storage-block = .label = { COPY(from_path, "persistentStorage.block.label") } .accesskey = { COPY(from_path, "persistentStorage.block.accesskey") } perm-web-notifications-allow = .label = { COPY(from_path, "webNotifications.allow2") } .accesskey = { COPY(from_path, "webNotifications.allow2.accesskey") } perm-web-notifications-always-block = .label = { COPY(from_path, "webNotifications.alwaysBlock") } .accesskey = { COPY(from_path, "webNotifications.alwaysBlock.accesskey") } perm-web-notifications-block = .label = { COPY(from_path, "webNotifications.block") } .accesskey = { COPY(from_path, "webNotifications.block.accesskey") } perm-localhost-allow = .label = { COPY(from_path, "localhost.allowlabel") } .accesskey = { COPY(from_path, "localhost.allow.accesskey") } perm-localhost-block = .label = { COPY(from_path, "localhost.blocklabel") } .accesskey = { COPY(from_path, "localhost.block.accesskey") } perm-local-network-allow = .label = { COPY(from_path, "localNetwork.allowLabel") } .accesskey = { COPY(from_path, "localNetwork.allow.accesskey") } perm-local-network-block = .label = { COPY(from_path, "localNetwork.blockLabel") } .accesskey = { COPY(from_path, "localNetwork.block.accesskey") } perm-midi-allow = .label = { COPY(from_path, "midi.allow.label") } .accesskey = { COPY(from_path, "midi.allow.accesskey") } perm-midi-block = .label = { COPY(from_path, "midi.block.label") } .accesskey = { COPY(from_path, "midi.block.accesskey") } perm-serial-allow = .label = { COPY(from_path, "serial.allow.label") } .accesskey = { COPY(from_path, "serial.allow.accesskey") } perm-serial-block = .label = { COPY(from_path, "serial.block.label") } .accesskey = { COPY(from_path, "serial.block.accesskey") } perm-storage-access-allow = .label = { COPY(from_path, "storageAccess1.Allow.label") } .accesskey = { COPY(from_path, "storageAccess1.Allow.accesskey") } perm-storage-access-block = .label = { COPY(from_path, "storageAccess1.DontAllow.label") } .accesskey = { COPY(from_path, "storageAccess1.DontAllow.accesskey") } perm-canvas-allow = .label = { COPY(from_path, "canvas.allow2") } .accesskey = { COPY(from_path, "canvas.allow2.accesskey") } perm-canvas-block = .label = { COPY(from_path, "canvas.block") } .accesskey = { COPY(from_path, "canvas.block.accesskey") } perm-geolocation-share-with-file = { COPY(from_path, "geolocation.shareWithFile4") } perm-geolocation-remember = { COPY(from_path, "geolocation.remember") } perm-fullscreen-prompt-canceled = { COPY(from_path, "permissions.fullscreen.promptCanceled") } perm-fullscreen-exited = { COPY(from_path, "permissions.fullscreen.fullScreenCanceled") } perm-xr-share-with-file = { COPY(from_path, "xr.shareWithFile4") } perm-xr-remember = { COPY(from_path, "xr.remember") } perm-localhost-remember = { COPY(from_path, "localhost.remember2") } perm-local-network-remember = { COPY(from_path, "localNetwork.remember2") } perm-midi-remember = { COPY(from_path, "midi.remember") } perm-midi-share-with-file = { COPY(from_path, "midi.shareWithFile") } perm-midi-share-sysex-with-file = { COPY(from_path, "midi.shareSysexWithFile") } perm-serial-share-with-file = { COPY(from_path, "serial.shareWithFile") } perm-canvas-site-prompt-warning = { COPY(from_path, "canvas.siteprompt2.warning") } perm-canvas-remember = { COPY(from_path, "canvas.remember2") } """, from_path=source, ), ) ctx.add_transforms( target, target, [ FTL.Message( id=FTL.Identifier("perm-geolocation-share-with-site"), value=REPLACE( source, "geolocation.shareWithSite4", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), FTL.Message( id=FTL.Identifier("perm-xr-share-with-site"), value=REPLACE( source, "xr.shareWithSite4", {"%1$S": VARIABLE_REFERENCE("host")} ), ), FTL.Message( id=FTL.Identifier("perm-persistent-storage-allow-with-site"), value=REPLACE( source, "persistentStorage.allowWithSite2", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), FTL.Message( id=FTL.Identifier("perm-web-notifications-receive-from-site"), value=REPLACE( source, "webNotifications.receiveFromSite3", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), FTL.Message( id=FTL.Identifier("perm-localhost-allow-with-site"), value=REPLACE( source, "localhost.allowWithSite2", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), FTL.Message( id=FTL.Identifier("perm-local-network-allow-with-site"), value=REPLACE( source, "localNetwork.allowWithSite2", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), FTL.Message( id=FTL.Identifier("perm-midi-share-with-site"), value=REPLACE( source, "midi.shareWithSite", {"%1$S": VARIABLE_REFERENCE("host")} ), ), FTL.Message( id=FTL.Identifier("perm-midi-share-sysex-with-site"), value=REPLACE( source, "midi.shareSysexWithSite", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), FTL.Message( id=FTL.Identifier("perm-serial-share-with-site"), value=REPLACE( source, "serial.shareWithSite", {"%1$S": VARIABLE_REFERENCE("host")} ), ), FTL.Message( id=FTL.Identifier("perm-canvas-site-prompt"), value=REPLACE( source, "canvas.siteprompt2", {"%1$S": VARIABLE_REFERENCE("host")} ), ), FTL.Message( id=FTL.Identifier("perm-geolocation-needs-system-setting"), value=REPLACE( source, "geolocation.needsSystemSetting", {"%1$S": TERM_REFERENCE("brand-short-name")}, ), ), FTL.Message( id=FTL.Identifier("perm-geolocation-system-will-request-permission"), value=REPLACE( source, "geolocation.systemWillRequestPermission", {"%1$S": TERM_REFERENCE("brand-short-name")}, ), ), FTL.Message( id=FTL.Identifier("perm-geolocation-share-with-site-unsafe-delegation"), value=REPLACE( source, "geolocation.shareWithSiteUnsafeDelegation2", { "%1$S": VARIABLE_REFERENCE("host"), "%2$S": VARIABLE_REFERENCE("thirdParty"), }, ), ), FTL.Message( id=FTL.Identifier("perm-storage-access-message"), value=REPLACE( source, "storageAccess4.message", { "%1$S": VARIABLE_REFERENCE("host"), "%2$S": VARIABLE_REFERENCE("embeddingHost"), }, ), ), FTL.Message( id=FTL.Identifier("perm-storage-access-hint"), value=REPLACE( source, "storageAccess1.hintText", {"%1$S": VARIABLE_REFERENCE("host")}, ), ), ], )