tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug_1971841_sync_device_name.py (1507B)


      1 # Any copyright is dedicated to the Public Domain.
      2 # http://creativecommons.org/publicdomain/zero/1.0/
      3 
      4 import re
      5 from fluent.migrate.transforms import TransformPattern, COPY_PATTERN
      6 import fluent.syntax.ast as FTL
      7 
      8 
      9 class STRIP_ELLIPSIS(TransformPattern):
     10    def visit_TextElement(self, node):
     11        node.value = re.sub(r"(?:…|\.\.\.)$", "", node.value)
     12        return node
     13 
     14 
     15 def migrate(ctx):
     16    """Bug 1971841 - Convert Sync section to config-based prefs, part {index}"""
     17    path = "browser/browser/preferences/preferences.ftl"
     18 
     19    ctx.add_transforms(
     20        path,
     21        path,
     22        [
     23            FTL.Message(
     24                id=FTL.Identifier("sync-device-name-input"),
     25                attributes=[
     26                    FTL.Attribute(
     27                        id=FTL.Identifier("aria-label"),
     28                        value=COPY_PATTERN(path, "sync-device-name-header"),
     29                    ),
     30                ],
     31            ),
     32            FTL.Message(
     33                id=FTL.Identifier("sync-device-name-change-2"),
     34                attributes=[
     35                    FTL.Attribute(
     36                        id=FTL.Identifier("label"),
     37                        value=STRIP_ELLIPSIS(path, "sync-device-name-change.label"),
     38                    ),
     39                    FTL.Attribute(
     40                        id=FTL.Identifier("accesskey"),
     41                        value=COPY_PATTERN(path, "sync-device-name-change.accesskey"),
     42                    ),
     43                ],
     44            ),
     45        ],
     46    )