summaryrefslogtreecommitdiffstats
path: root/python/l10n/fluent_migrations/bug_1635548_browser_context.py
blob: 33bd0efc95550c9d9af2807aad39cc0038334755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# coding=utf8

# 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
from fluent.migrate import REPLACE, COPY


def migrate(ctx):
    """Bug 1635548 - Migrate browser-context.inc to Fluent, part {index}"""
    target = "toolkit/toolkit/global/textActions.ftl"
    reference = "toolkit/toolkit/global/textActions.ftl"
    ctx.add_transforms(
        target,
        reference,
        transforms_from(
            """
text-action-spell-add-to-dictionary =
    .label = { COPY(from_path, "spellAddToDictionary.label") }
    .accesskey = { COPY(from_path, "spellAddToDictionary.accesskey") }

text-action-spell-undo-add-to-dictionary =
    .label = { COPY(from_path, "spellUndoAddToDictionary.label") }
    .accesskey = { COPY(from_path, "spellUndoAddToDictionary.accesskey") }

text-action-spell-check-toggle =
    .label = { COPY(from_path, "spellCheckToggle.label") }
    .accesskey = { COPY(from_path, "spellCheckToggle.accesskey") }

text-action-spell-dictionaries =
    .label = { COPY(from_path, "spellDictionaries.label") }
    .accesskey = { COPY(from_path, "spellDictionaries.accesskey") }
""",
            from_path="toolkit/chrome/global/textcontext.dtd",
        ),
    )

    target = "toolkit/toolkit/global/textActions.ftl"
    reference = "toolkit/toolkit/global/textActions.ftl"
    ctx.add_transforms(
        target,
        reference,
        transforms_from(
            """
text-action-spell-add-dictionaries =
    .label = { COPY(from_path, "spellAddDictionaries.label") }
    .accesskey = { COPY(from_path, "spellAddDictionaries.accesskey") }
""",
            from_path="browser/chrome/browser/browser.dtd",
        ),
    )

    target = "browser/browser/browserContext.ftl"
    reference = "browser/browser/browserContext.ftl"
    ctx.add_transforms(
        target,
        reference,
        [
            FTL.Message(
                id=FTL.Identifier("main-context-menu-open-link-in-container-tab"),
                attributes=[
                    FTL.Attribute(
                        FTL.Identifier("label"),
                        REPLACE(
                            "browser/chrome/browser/browser.properties",
                            "userContextOpenLink.label",
                            {"%1$S": VARIABLE_REFERENCE("containerName")},
                        ),
                    ),
                    FTL.Attribute(
                        FTL.Identifier("accesskey"),
                        COPY(
                            "browser/chrome/browser/browser.dtd",
                            "openLinkCmdInTab.accesskey",
                        ),
                    ),
                ],
            )
        ],
    )