Skip to content

Commit 59ab83b

Browse files
committed
react: remove react-i18n dependency
1 parent 010c5f4 commit 59ab83b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+446
-480
lines changed

.changeset/famous-glasses-sleep.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@treasure-dev/tdk-react": minor
33
---
44

5-
Removed `tailwind-merge` dependency for ~70Kb savings in gzipped package
5+
Removed `tailwind-merge` dependency for ~7Kb savings in gzipped package

.changeset/kind-mails-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@treasure-dev/tdk-react": minor
3+
---
4+
5+
Removed `react-i18n` dependency for ~20Kb savings in gzipped package

packages/react/.storybook/preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Preview } from "@storybook/react";
33
import React from "react";
44
import { ThirdwebProvider } from "thirdweb/react";
55

6-
import { TreasureProvider } from "../src/contexts/treasure";
6+
import { TreasureProvider } from "../src/providers/treasure";
77

88
import "../src/globals.css";
99

packages/react/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,7 @@
4747
"@treasure-dev/launcher": "workspace:*",
4848
"class-variance-authority": "catalog:",
4949
"clsx": "catalog:",
50-
"i18next": "catalog:",
51-
"i18next-browser-languagedetector": "catalog:",
52-
"input-otp": "catalog:",
53-
"react-i18next": "catalog:"
50+
"input-otp": "catalog:"
5451
},
5552
"devDependencies": {
5653
"@storybook/addon-essentials": "catalog:",

packages/react/src/components/ui/Dialog.tsx

Lines changed: 0 additions & 55 deletions
This file was deleted.

packages/react/src/hooks/useContractAddress.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
getContractAddress,
44
getContractAddresses,
55
} from "@treasure-dev/tdk-core";
6-
import { useTreasure } from "../contexts/treasure";
6+
7+
import { useTreasure } from "../providers/treasure";
78

89
export const useContractAddress = ({
910
chainId,

packages/react/src/i18n.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/react/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import "./globals.css";
22

33
export type * from "@treasure-dev/tdk-core";
44

5-
export { ConnectButton } from "./components/connect/ConnectButton";
6-
export { ConnectModal } from "./components/connect/ConnectModal";
7-
export { Button } from "./components/ui/Button";
8-
export { TreasureProvider, useTreasure } from "./contexts/treasure";
9-
export { useConnect } from "./hooks/useConnect";
5+
export { ConnectButton } from "./ui/ConnectButton/ConnectButton";
6+
export { ConnectModal } from "./ui/ConnectModal/ConnectModal";
7+
export { Button } from "./ui/components/Button";
8+
export { TreasureProvider, useTreasure } from "./providers/treasure";
9+
export { useConnect } from "./ui/hooks/useConnect";
1010
export {
1111
useContractAddress,
1212
useContractAddresses,

packages/react/src/contexts/treasure.tsx renamed to packages/react/src/providers/treasure.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
useMemo,
2727
useState,
2828
} from "react";
29-
import { I18nextProvider } from "react-i18next";
3029
import { ZERO_ADDRESS, defineChain } from "thirdweb";
3130
import {
3231
useActiveWallet,
@@ -39,9 +38,8 @@ import {
3938
import { isZkSyncChain } from "thirdweb/utils";
4039
import { type Wallet, ecosystemWallet } from "thirdweb/wallets";
4140

42-
import { useLauncher } from "../hooks/useLauncher";
43-
import { i18n } from "../i18n";
4441
import type { AnalyticsEvent, Config, ContextValues } from "../types";
42+
import { useLauncher } from "../ui/hooks/useLauncher";
4543
import {
4644
EVT_TREASURECONNECT_CONNECTED,
4745
EVT_TREASURECONNECT_DISCONNECTED,
@@ -68,8 +66,9 @@ export const useTreasure = () => {
6866

6967
type Props = PropsWithChildren<Config>;
7068

71-
const TreasureProviderInner = ({
69+
export const TreasureProvider = ({
7270
children,
71+
language,
7372
appName,
7473
appIconUri,
7574
apiUri = DEFAULT_TDK_API_BASE_URI,
@@ -360,6 +359,7 @@ const TreasureProviderInner = ({
360359
return (
361360
<Context.Provider
362361
value={{
362+
language,
363363
appName,
364364
appIconUri,
365365
chain,
@@ -409,17 +409,3 @@ const TreasureProviderInner = ({
409409
</Context.Provider>
410410
);
411411
};
412-
413-
export const TreasureProvider = (props: Props) => {
414-
useEffect(() => {
415-
if (props.language) {
416-
i18n.changeLanguage(props.language);
417-
}
418-
}, [props.language]);
419-
420-
return (
421-
<I18nextProvider i18n={i18n}>
422-
<TreasureProviderInner {...props} />
423-
</I18nextProvider>
424-
);
425-
};

packages/react/src/translations/en.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { ReactNode } from "react";
2+
3+
const translation = {
4+
connect: {
5+
action: "Connect",
6+
header: ({ appName }: { appName: ReactNode }) => <>Connect to {appName}</>,
7+
footer: ({ thirdweb }: { thirdweb: ReactNode }) => (
8+
<>Powered by {thirdweb}</>
9+
),
10+
option: {
11+
email: "Email address",
12+
or: "or",
13+
apple: "Apple",
14+
discord: "Discord",
15+
google: "Google",
16+
passkey: "Passkey",
17+
wallet: "Wallet",
18+
x: "X",
19+
},
20+
verify: {
21+
header: "Verify code",
22+
description: ({ recipient }: { recipient: ReactNode }) => (
23+
<>
24+
We have sent a verification code to {recipient}. You will be
25+
automatically logged in after entering your code.
26+
</>
27+
),
28+
inputLabel: "Enter verification code:",
29+
action: "Confirm",
30+
resend: {
31+
prompt: "Didn't get a code?",
32+
action: "Resend",
33+
countdown: ({ seconds }: { seconds: number }) =>
34+
`Resend available in ${seconds}s...`,
35+
},
36+
},
37+
migrate: {
38+
header: "Migrate existing account",
39+
description:
40+
"It looks like you have several existing Treasure profiles. Please choose one you would like to use moving forward as your identity across the Treasure ecosystem.",
41+
approve: "Use this account",
42+
reject: "Start fresh",
43+
disclaimer: "NOTE: This is irreversible, so please choose carefully.",
44+
},
45+
},
46+
};
47+
48+
export type Translation = typeof translation;
49+
50+
export default translation;

packages/react/src/translations/es.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import type { Translation } from "./en";
2+
3+
const translation: Translation = {
4+
connect: {
5+
action: "Conectar",
6+
header: ({ appName }) => <>Conectarse a {appName}</>,
7+
footer: ({ thirdweb }) => <>Con tecnología de {thirdweb}</>,
8+
option: {
9+
email: "Correo electrónico",
10+
or: "o",
11+
apple: "Apple",
12+
discord: "Discord",
13+
google: "Google",
14+
passkey: "Clave de paso",
15+
wallet: "Cartera",
16+
x: "X",
17+
},
18+
verify: {
19+
header: "Verificar código",
20+
description: ({ recipient }) => (
21+
<>
22+
Se envió un código de verificación a {recipient}. Iniciará sesión
23+
automáticamente después de ingresar su código.
24+
</>
25+
),
26+
inputLabel: "Ingresar código de verificación:",
27+
action: "Confirmar",
28+
resend: {
29+
prompt: "¿No recibió un código?",
30+
action: "Reenviar",
31+
countdown: ({ seconds }: { seconds: number }) =>
32+
`Reenvío disponsible en ${seconds}s...`,
33+
},
34+
},
35+
migrate: {
36+
header: "Migrate existing account",
37+
description:
38+
"It looks like you have several existing Treasure profiles. Please choose one you would like to use moving forward as your identity across the Treasure ecosystem.",
39+
approve: "Use this account",
40+
reject: "Start fresh",
41+
disclaimer: "NOTE: This is irreversible, so please choose carefully.",
42+
},
43+
},
44+
};
45+
46+
export default translation;

0 commit comments

Comments
 (0)