MCPcopy Create free account
hub / github.com/i18next/react-i18next / ComponentUsingMacro

Function ComponentUsingMacro

example/react-icu/src/ComponentUsingMacro.js:13–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11/* eslint-disable no-undef, no-sequences */
12// prettier-ignore
13export function ComponentUsingMacro() {
14 const name = 'John Doe';
15 const itemsCount1 = 0;
16 const itemsCount2 = 1;
17 const itemsCount3 = 199;
18 const trainersCount = 134567;
19
20 const catchDate = new Date();
21 const gender = 'female';
22
23
24 return (
25 <div>
26 <hr />
27 <p><i>Using babel macro plugin to transpile icu containing nodes into valid Trans component:</i></p>
28
29
30 <p><i>interpolation:</i></p>
31 <Trans>Welcome, { name }!</Trans>
32 <br />
33 <Trans>Welcome, <strong>{ name }</strong>!</Trans>
34 <br />
35 <Trans>Trainers: { trainersCount, number }</Trans>
36 <br />
37 <Trans>Trainers: <strong>{ trainersCount, number }</strong>!</Trans>
38 <br />
39 <Trans>Caught on { catchDate, date, full }</Trans>
40 <br />
41 <Trans>Caught on <strong>{ catchDate, date, full }</strong>!</Trans>
42
43 <p><i>select:</i></p>
44 <Select
45 switch={gender}
46 male="He avoids bugs."
47 female="She avoids bugs."
48 other="They avoid bugs."
49 />
50 <br />
51 <Select
52 switch={gender}
53 male={<Trans><strong>He</strong> avoids bugs.</Trans>}
54 female={<Trans><strong>She</strong> avoids bugs.</Trans>}
55 other={<Trans><strong>They</strong> avoid bugs.</Trans>}
56 />
57
58 <p><i>plurals:</i></p>
59 <Plural
60 count={itemsCount1}
61 $0="There is no item."
62 one="There is # item."
63 other="There are # items."
64 />
65 <br />
66 <Plural
67 count={itemsCount2}
68 $0="There is no item."
69 one="There is # item."
70 other="There are # items."

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected