summaryrefslogtreecommitdiffstats
path: root/python/l10n/fluent_migrations/bug_1831851_accounts.py
blob: d50a0192c882fb7d90a19ea5546b3e622cf3b4be (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# 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 VARIABLE_REFERENCE
from fluent.migrate.transforms import COPY, PLURALS, REPLACE, REPLACE_IN_TEXT


def migrate(ctx):
    """Bug 1831851 - Migrate accounts.properties to Fluent, part {index}."""

    accounts = "browser/chrome/browser/accounts.properties"
    accounts_ftl = "browser/browser/accounts.ftl"
    preferences_ftl = "browser/browser/preferences/preferences.ftl"

    ctx.add_transforms(
        accounts_ftl,
        accounts_ftl,
        [
            FTL.Message(
                id=FTL.Identifier("account-reconnect"),
                value=REPLACE(
                    accounts,
                    "reconnectDescription",
                    {"%1$S": VARIABLE_REFERENCE("email")},
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-verify"),
                value=REPLACE(
                    accounts, "verifyDescription", {"%1$S": VARIABLE_REFERENCE("email")}
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-send-to-all-devices-titlecase"),
                value=COPY(accounts, "sendToAllDevices.menuitem"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-manage-devices-titlecase"),
                value=COPY(accounts, "manageDevices.menuitem"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-send-tab-to-device-singledevice-status"),
                value=COPY(accounts, "sendTabToDevice.singledevice.status"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-send-tab-to-device-singledevice-learnmore"),
                value=COPY(accounts, "sendTabToDevice.singledevice"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-send-tab-to-device-connectdevice"),
                value=COPY(accounts, "sendTabToDevice.connectdevice"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-send-tab-to-device-verify-status"),
                value=COPY(accounts, "sendTabToDevice.verify.status"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-send-tab-to-device-verify"),
                value=COPY(accounts, "sendTabToDevice.verify"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-connection-title"),
                value=FTL.Pattern(
                    [
                        FTL.Placeable(
                            FTL.TermReference(
                                id=FTL.Identifier("fxaccount-brand-name"),
                                arguments=FTL.CallArguments(
                                    named=[
                                        FTL.NamedArgument(
                                            FTL.Identifier("capitalization"),
                                            FTL.StringLiteral("title"),
                                        )
                                    ]
                                ),
                            )
                        )
                    ]
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-connection-connected-with"),
                value=REPLACE(
                    accounts,
                    "otherDeviceConnectedBody",
                    {"%1$S": VARIABLE_REFERENCE("deviceName")},
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-connection-connected-with-noname"),
                value=COPY(accounts, "otherDeviceConnectedBody.noDeviceName"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-connection-connected"),
                value=COPY(accounts, "thisDeviceConnectedBody"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-connection-disconnected"),
                value=COPY(accounts, "thisDeviceDisconnectedBody"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-single-tab-arriving-title"),
                value=COPY(accounts, "tabArrivingNotification.title"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-single-tab-arriving-from-device-title"),
                value=REPLACE(
                    accounts,
                    "tabArrivingNotificationWithDevice.title",
                    {"%1$S": VARIABLE_REFERENCE("deviceName")},
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-single-tab-arriving-truncated-url"),
                value=REPLACE(
                    accounts,
                    "singleTabArrivingWithTruncatedURL.body",
                    {"%1$S": VARIABLE_REFERENCE("url")},
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-multiple-tabs-arriving-title"),
                value=COPY(accounts, "multipleTabsArrivingNotification.title"),
            ),
            FTL.Message(
                id=FTL.Identifier("account-multiple-tabs-arriving-from-single-device"),
                value=PLURALS(
                    accounts,
                    "unnamedTabsArrivingNotification2.body",
                    VARIABLE_REFERENCE("tabCount"),
                    foreach=lambda n: REPLACE_IN_TEXT(
                        n,
                        {
                            "#1": VARIABLE_REFERENCE("tabCount"),
                            "#2": VARIABLE_REFERENCE("deviceName"),
                        },
                    ),
                ),
            ),
            FTL.Message(
                id=FTL.Identifier(
                    "account-multiple-tabs-arriving-from-multiple-devices"
                ),
                value=PLURALS(
                    accounts,
                    "unnamedTabsArrivingNotificationMultiple2.body",
                    VARIABLE_REFERENCE("tabCount"),
                    foreach=lambda n: REPLACE_IN_TEXT(
                        n,
                        {"#1": VARIABLE_REFERENCE("tabCount")},
                    ),
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("account-multiple-tabs-arriving-from-unknown-device"),
                value=PLURALS(
                    accounts,
                    "unnamedTabsArrivingNotificationNoDevice.body",
                    VARIABLE_REFERENCE("tabCount"),
                    foreach=lambda n: REPLACE_IN_TEXT(
                        n,
                        {"#1": VARIABLE_REFERENCE("tabCount")},
                    ),
                ),
            ),
        ],
    )

    ctx.add_transforms(
        preferences_ftl,
        preferences_ftl,
        [
            FTL.Message(
                id=FTL.Identifier("sync-verification-sent-title"),
                value=COPY(accounts, "verificationSentTitle"),
            ),
            FTL.Message(
                id=FTL.Identifier("sync-verification-sent-body"),
                value=REPLACE(
                    accounts,
                    "verificationSentBody",
                    {"%1$S": VARIABLE_REFERENCE("email")},
                ),
            ),
            FTL.Message(
                id=FTL.Identifier("sync-verification-not-sent-title"),
                value=COPY(accounts, "verificationNotSentTitle"),
            ),
            FTL.Message(
                id=FTL.Identifier("sync-verification-not-sent-body"),
                value=COPY(accounts, "verificationNotSentBody"),
            ),
        ],
    )