tor-browser

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

bug_1971628_preferences_appearance.py (3150B)


      1 # Any copyright is dedicated to the Public Domain.
      2 # http://creativecommons.org/publicdomain/zero/1.0/
      3 
      4 import re
      5 import fluent.syntax.ast as FTL
      6 from fluent.migrate import COPY_PATTERN
      7 from fluent.migrate.transforms import TransformPattern
      8 
      9 
     10 class STRIP_LINK(TransformPattern):
     11    def visit_TextElement(self, node):
     12        node.value = re.sub(r"</?a\b[^>]*>", "", node.value)
     13        return node
     14 
     15 
     16 def migrate(ctx):
     17    """Bug 1971628 - Migrate web appearance footer text to .label without link, transform and condense theme strings part {index}."""
     18    path = "browser/browser/preferences/preferences.ftl"
     19    ctx.add_transforms(
     20        path,
     21        path,
     22        [
     23            FTL.Message(
     24                id=FTL.Identifier("preferences-web-appearance-link"),
     25                attributes=[
     26                    FTL.Attribute(
     27                        id=FTL.Identifier("label"),
     28                        value=STRIP_LINK(path, "preferences-web-appearance-footer"),
     29                    ),
     30                ],
     31            ),
     32            FTL.Message(
     33                id=FTL.Identifier("preferences-web-appearance-choice-auto2"),
     34                attributes=[
     35                    FTL.Attribute(
     36                        id=FTL.Identifier("label"),
     37                        value=COPY_PATTERN(
     38                            path, "preferences-web-appearance-choice-auto"
     39                        ),
     40                    ),
     41                    FTL.Attribute(
     42                        id=FTL.Identifier("title"),
     43                        value=COPY_PATTERN(
     44                            path, "preferences-web-appearance-choice-tooltip-auto.title"
     45                        ),
     46                    ),
     47                ],
     48            ),
     49            FTL.Message(
     50                id=FTL.Identifier("preferences-web-appearance-choice-light2"),
     51                attributes=[
     52                    FTL.Attribute(
     53                        id=FTL.Identifier("label"),
     54                        value=COPY_PATTERN(
     55                            path, "preferences-web-appearance-choice-light"
     56                        ),
     57                    ),
     58                    FTL.Attribute(
     59                        id=FTL.Identifier("title"),
     60                        value=COPY_PATTERN(
     61                            path,
     62                            "preferences-web-appearance-choice-tooltip-light.title",
     63                        ),
     64                    ),
     65                ],
     66            ),
     67            FTL.Message(
     68                id=FTL.Identifier("preferences-web-appearance-choice-dark2"),
     69                attributes=[
     70                    FTL.Attribute(
     71                        id=FTL.Identifier("label"),
     72                        value=COPY_PATTERN(
     73                            path, "preferences-web-appearance-choice-dark"
     74                        ),
     75                    ),
     76                    FTL.Attribute(
     77                        id=FTL.Identifier("title"),
     78                        value=COPY_PATTERN(
     79                            path, "preferences-web-appearance-choice-tooltip-dark.title"
     80                        ),
     81                    ),
     82                ],
     83            ),
     84        ],
     85    )