Debian Codegraph @

python/l10n/fluent_migrations/bug_1897411_sidebar_widget_label.py

raw
1 # Any copyright is dedicated to the Public Domain.
2 # http://creativecommons.org/publicdomain/zero/1.0/
3
4 import fluent.syntax.ast as FTL
5 from fluent.migrate import COPY_PATTERN
6 from fluent.migrate.transforms import TransformPattern
7 from fluent.migrate.transforms import COPY
8
9
10 class ADD_SHORTCUT(TransformPattern):
11 def visit_TextElement(self, node):
12 node.value = f"{node.value} ({{ $shortcut }})"
13 return node
14
15
16 def migrate(ctx):
17 """Bug 1897411 - Add keyboard shortcut for expanding the sidebar, part {index}."""
18
19 properties_file = (
20 "browser/chrome/browser/customizableui/customizableWidgets.properties"
21 )
22 ftl_file = "browser/browser/sidebar.ftl"
23 ctx.add_transforms(
24 ftl_file,
25 ftl_file,
26 [
27 FTL.Message(
28 id=FTL.Identifier("sidebar-widget-expand-sidebar2"),
29 attributes=[
30 FTL.Attribute(
31 id=FTL.Identifier("tooltiptext"),
32 value=ADD_SHORTCUT(
33 ftl_file, "sidebar-widget-expand-sidebar.tooltiptext"
34 ),
35 ),
36 FTL.Attribute(
37 id=FTL.Identifier("label"),
38 value=COPY(properties_file, "sidebar-button.label"),
39 ),
40 ],
41 ),
42 FTL.Message(
43 id=FTL.Identifier("sidebar-widget-collapse-sidebar2"),
44 attributes=[
45 FTL.Attribute(
46 id=FTL.Identifier("tooltiptext"),
47 value=ADD_SHORTCUT(
48 ftl_file, "sidebar-widget-collapse-sidebar.tooltiptext"
49 ),
50 ),
51 FTL.Attribute(
52 id=FTL.Identifier("label"),
53 value=COPY(properties_file, "sidebar-button.label"),
54 ),
55 ],
56 ),
57 FTL.Message(
58 id=FTL.Identifier("sidebar-widget-show-sidebar2"),
59 attributes=[
60 FTL.Attribute(
61 id=FTL.Identifier("tooltiptext"),
62 value=ADD_SHORTCUT(
63 ftl_file, "sidebar-widget-show-sidebar.tooltiptext"
64 ),
65 ),
66 FTL.Attribute(
67 id=FTL.Identifier("label"),
68 value=COPY(properties_file, "sidebar-button.label"),
69 ),
70 ],
71 ),
72 FTL.Message(
73 id=FTL.Identifier("sidebar-widget-hide-sidebar2"),
74 attributes=[
75 FTL.Attribute(
76 id=FTL.Identifier("tooltiptext"),
77 value=ADD_SHORTCUT(
78 ftl_file, "sidebar-widget-hide-sidebar.tooltiptext"
79 ),
80 ),
81 FTL.Attribute(
82 id=FTL.Identifier("label"),
83 value=COPY(properties_file, "sidebar-button.label"),
84 ),
85 ],
86 ),
87 FTL.Message(
88 id=FTL.Identifier("show-sidebars"),
89 attributes=[
90 FTL.Attribute(
91 id=FTL.Identifier("tooltiptext"),
92 value=COPY(properties_file, "sidebar-button.tooltiptext2"),
93 ),
94 FTL.Attribute(
95 id=FTL.Identifier("label"),
96 value=COPY(properties_file, "sidebar-button.label"),
97 ),
98 ],
99 ),
100 ],
101 )