tor-browser

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

bug_1971835_sync_preferences_update.py (1670B)


      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 1971835 - Update account preferences strings, part {index}."""
     17 
     18    source = "browser/browser/preferences/preferences.ftl"
     19 
     20    ctx.add_transforms(
     21        source,
     22        source,
     23        [
     24            FTL.Message(
     25                id=FTL.Identifier("sync-sign-out2"),
     26                attributes=[
     27                    FTL.Attribute(
     28                        id=FTL.Identifier("label"),
     29                        value=STRIP_ELLIPSIS(source, "sync-sign-out.label"),
     30                    ),
     31                    FTL.Attribute(
     32                        id=FTL.Identifier("accesskey"),
     33                        value=COPY_PATTERN(source, "sync-sign-out.accesskey"),
     34                    ),
     35                ],
     36            ),
     37            FTL.Message(
     38                id=FTL.Identifier("sync-manage-account2"),
     39                attributes=[
     40                    FTL.Attribute(
     41                        id=FTL.Identifier("label"),
     42                        value=COPY_PATTERN(source, "sync-manage-account"),
     43                    ),
     44                    FTL.Attribute(
     45                        id=FTL.Identifier("accesskey"),
     46                        value=COPY_PATTERN(source, "sync-manage-account.accesskey"),
     47                    ),
     48                ],
     49            ),
     50        ],
     51    )