Skip to content

Commit 5c9f7ea

Browse files
authored
Merge pull request #9085 from ethereum/setupEnergyConsumptionChartTranslation
setup energy consumption chart labels for translation
2 parents 6ede023 + 803ae81 commit 5c9f7ea

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

src/components/EnergyConsumptionChart.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import {
77
Cell,
88
XAxis,
99
Text,
10-
CartesianGrid,
1110
LabelList,
1211
ResponsiveContainer,
1312
Legend,
1413
} from "recharts"
14+
import { useIntl } from "react-intl"
1515
import Translation from "./Translation"
1616
import { useWindowSize } from "../hooks/useWindowSize"
17+
import { translateMessageId } from "../utils/translations"
1718

1819
interface ITickProps {
1920
x: number
@@ -43,6 +44,7 @@ const CustomTick: React.FC<ITickProps> = ({ x, y, payload }) => {
4344
}
4445

4546
const EnergyConsumptionChart: React.FC = () => {
47+
const intl = useIntl()
4648
const theme = useTheme()
4749
const [width] = useWindowSize()
4850

@@ -59,58 +61,70 @@ const EnergyConsumptionChart: React.FC = () => {
5961
// TODO: Extract translatable strings
6062
const energyConsumptionChartData: Data = [
6163
{
62-
name: "YouTube",
64+
name: translateMessageId("energy-consumption-chart-youtube-label", intl),
6365
amount: 244,
6466
color: "#FF0000",
6567
},
6668
{
67-
name: "Gold mining (Galaxy Digital)",
69+
name: translateMessageId(
70+
"energy-consumption-chart-gold-mining-galaxy-label",
71+
intl
72+
),
6873
amount: 240,
6974
color: "#D7B14A",
7075
breakpoint: mediumBreakpoint,
7176
},
7277
{
73-
name: "Global data centers",
78+
name: translateMessageId(
79+
"energy-consumption-chart-global-data-centers-label",
80+
intl
81+
),
7482
amount: 200,
7583
color: "#D7B14A",
7684
breakpoint: mediumBreakpoint,
7785
},
7886
{
79-
name: "Gold mining (CBECI)",
87+
name: translateMessageId(
88+
"energy-consumption-chart-gold-mining-cbeci-label",
89+
intl
90+
),
8091
amount: 130,
8192
color: "#D7B14A",
8293
breakpoint: mediumBreakpoint,
8394
},
8495
{
85-
name: "BTC PoW",
96+
name: translateMessageId("energy-consumption-chart-btc-pow-label", intl),
8697
amount: 100,
8798
color: "#F2A900",
8899
},
89100
{
90-
name: "Netflix",
101+
name: translateMessageId("energy-consumption-chart-netflix-label", intl),
91102
amount: 94,
92103
color: "#E50914",
93104
breakpoint: smallBreakpoint,
94105
},
95106
{
96-
name: "ETH PoW",
107+
name: translateMessageId("energy-consumption-chart-eth-pow-label", intl),
97108
amount: 78,
98109
color: "#C1B6F5",
99110
},
100111
{
101-
name: "Gaming in the US",
112+
name: translateMessageId(
113+
"energy-consumption-chart-gaming-us-label",
114+
intl
115+
),
102116
amount: 34,
103117
color: "#71BB8A",
104118
breakpoint: mediumBreakpoint,
105119
},
106120
{
107-
name: "PayPal",
121+
name: translateMessageId("energy-consumption-chart-paypal-label", intl),
108122
amount: 0.26,
109123
color: "#C1B6F5",
110124
breakpoint: smallBreakpoint,
111125
},
112126
{
113-
name: "ETH PoS",
127+
name: translateMessageId("energy-consumption-chart-eth-pos-label", intl),
114128
amount: 0.0026,
115129
color: "#C1B6F5",
116130
},

src/intl/en/page-what-is-ethereum.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@
8888
"page-what-is-ethereum-energy-desc-2": "The Merge was Ethereum's biggest uprade and reduced the energy consumption required to secure Ethereum by <b>99.95%</b>, creating a <b>more secure network for a much smaller carbon cost</b>. Ethereum is now a low-carbon blockchain while boosting its security and scalability.",
8989
"page-what-is-ethereum-more-on-energy-consumption": "More on energy consumption",
9090
"page-what-is-ethereum-energy-consumption-chart-legend": "Annual Energy Consumption in TWh/yr",
91+
"energy-consumption-chart-youtube-label": "YouTube",
92+
"energy-consumption-chart-gold-mining-galaxy-label": "Gold mining (Galaxy Digital)",
93+
"energy-consumption-chart-global-data-centers-label": "Global data centers",
94+
"energy-consumption-chart-gold-mining-cbeci-label": "Gold mining (CBECI)",
95+
"energy-consumption-chart-btc-pow-label": "BTC PoW",
96+
"energy-consumption-chart-netflix-label": "Netflix",
97+
"energy-consumption-chart-eth-pow-label": "ETH PoW",
98+
"energy-consumption-chart-gaming-us-label": "Gaming in the US",
99+
"energy-consumption-chart-paypal-label": "PayPal",
100+
"energy-consumption-chart-eth-pos-label": "ETH PoS",
91101
"page-what-is-ethereum-the-merge-update": "The Merge update",
92102
"page-what-is-ethereum-additional-reading": "Additional reading",
93103
"page-what-is-ethereum-week-in-ethereum": "Week in Ethereum News",

0 commit comments

Comments
 (0)