Skip to content

Commit cefe6aa

Browse files
author
Sergio
committed
feat: added a complete example
1 parent 9230ce4 commit cefe6aa

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from "react";
2+
import { NumberFormat, DateFormat, Trans, withI18n } from "@lingui/react"
3+
import { plural } from "@lingui/macro"
4+
5+
const App = ({ i18n }) => {
6+
return (
7+
<div>
8+
<div>
9+
<NumberFormat value={1_000_000} format={{ currency: "EUR" }} />
10+
</div>
11+
<div>
12+
<DateFormat value={new Date()} format={{ hour12: true }} />
13+
</div>
14+
<Trans>Component to replace</Trans>
15+
{/* TODO: if there isn't any with children we should keep lingui/react */}
16+
<Trans id="msg.id" />
17+
{plural({ value, one: "# book", other: "# books" })}
18+
{i18n._(t`some_string`)}
19+
{i18n._(plural({ value, one: "# book", other: "# books" }))}
20+
{i18n._(select({ value, one: "# book", other: "# books" }))}
21+
{i18n._(selectOrdinal({ value, one: "# book", other: "# books" }))}
22+
</div>
23+
)
24+
}
25+
26+
export default withI18n()(App)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from "react";
2+
import { number, date } from "@lingui/core";
3+
import { withI18n } from "@lingui/react";
4+
import { plural, Trans } from "@lingui/macro";
5+
6+
const App = ({ i18n }) => {
7+
return (
8+
<div>
9+
<div>
10+
{number(1_000_000, { currency: "EUR" })}
11+
</div>
12+
<div>
13+
{date(new Date(), { hour12: true })}
14+
</div>
15+
<Trans>Component to replace</Trans>
16+
{/* TODO: if there isn't any with children we should keep lingui/react */}
17+
<Trans id="msg.id" />
18+
{plural(value, {
19+
one: "# book",
20+
other: "# books"
21+
})}
22+
{t`some_string`}
23+
{plural(value, {
24+
one: "# book",
25+
other: "# books"
26+
})}
27+
{select({ value, one: "# book", other: "# books" })}
28+
{selectOrdinal({ value, one: "# book", other: "# books" })}
29+
</div>
30+
);
31+
}
32+
33+
export default withI18n()(App)

transforms/__tests__/v2-to-v3.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,13 @@ describe("Deprecated methods from @lingui/react transform the JSX", () => {
4444
null,
4545
"v2-to-v3/jsxTransformMacros",
4646
);
47+
});
48+
49+
describe("Complete example with all the past actions", () => {
50+
defineTest(
51+
__dirname,
52+
"v2-to-v3",
53+
null,
54+
"v2-to-v3/complete",
55+
);
4756
});

0 commit comments

Comments
 (0)