Skip to content

Commit 50f73b3

Browse files
committed
chore: fix comments
1 parent 09bd51d commit 50f73b3

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

packages/wallet-ui/src/components/ui/molecule/TransactionsList/TransactionListItem/TransactionListItem.view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const TransactionListItemView = ({ transaction }: Props) => {
4747
const [txnUsdValue, setTxnUsdValue] = useState('0.00');
4848
const { translate } = useMultiLanguage();
4949

50-
const { language } = useAppSelector((state) => state.wallet);
50+
const { locale } = useAppSelector((state) => state.wallet);
5151

5252
useEffect(() => {
5353
const fetchData = async () => {
@@ -74,7 +74,7 @@ export const TransactionListItemView = ({ transaction }: Props) => {
7474
}, []);
7575

7676
const txnName = getTxnName(transaction, tokenAddress);
77-
const txnDate = getTxnDate(transaction, language);
77+
const txnDate = getTxnDate(transaction, locale);
7878
const txnStatus = getTxnStatus(transaction);
7979
const txnToFromLabel = '';
8080
const txnFailureReason = getTxnFailureReason(transaction);

packages/wallet-ui/src/services/useMultiLanguage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useAppSelector } from 'hooks/redux';
22

33
export const useMultiLanguage = () => {
4-
const { locale } = useAppSelector((state) => state.wallet);
4+
const { translations } = useAppSelector((state) => state.wallet);
55

66
const translate = (key: string, ...args: (string | undefined)[]): string => {
7-
const template = locale[key]?.message ?? `{${key}}`;
7+
const template = translations[key]?.message ?? `{${key}}`;
88

99
return template.replace(/\{(\d+)\}/g, (_, index: string) => {
1010
const argIndex = parseInt(index, 10) - 1;

packages/wallet-ui/src/services/useStarkNetSnap.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {
1414
setTransactions,
1515
setTransactionDeploy,
1616
setForceReconnect,
17-
setLanguage,
1817
setLocale,
18+
setTranslations,
1919
} from '../slices/walletSlice';
2020
import Toastr from 'toastr2';
2121
import {
@@ -110,9 +110,9 @@ export const useStarkNetSnap = () => {
110110
});
111111
};
112112

113-
const loadPreferences = async () => {
113+
const loadLocale = async () => {
114114
try {
115-
const { locale: userLocale } = await provider.request({
115+
const { locale } = await provider.request({
116116
method: 'wallet_invokeSnap',
117117
params: {
118118
snapId,
@@ -121,9 +121,9 @@ export const useStarkNetSnap = () => {
121121
},
122122
},
123123
});
124-
const messages = await import(`../assets/locales/${userLocale}.json`);
125-
dispatch(setLanguage(userLocale as string));
126-
dispatch(setLocale(messages.messages));
124+
const messages = await import(`../assets/locales/${locale}.json`);
125+
dispatch(setLocale(locale));
126+
dispatch(setTranslations(messages.messages));
127127
} catch (error) {
128128
console.error(
129129
'Failed to load user preferences. Falling back to default locale.',
@@ -257,7 +257,7 @@ export const useStarkNetSnap = () => {
257257
dispatch(setActiveNetwork(idx));
258258
const chainId = net.chainId;
259259
await getWalletData(chainId, nets);
260-
await loadPreferences();
260+
await loadLocale();
261261
} catch (err: any) {
262262
if (err.code && err.code === 4100) {
263263
const toastr = new Toastr();

packages/wallet-ui/src/slices/walletSlice.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import defaultLocale from '../assets/locales/en.json';
88
export interface WalletState {
99
connected: boolean;
1010
isLoading: boolean;
11-
language: string;
12-
locale: Locale;
11+
locale: string;
12+
translations: Locale;
1313
forceReconnect: boolean;
1414
accounts: Account[];
1515
erc20TokenBalances: Erc20TokenBalance[];
@@ -22,8 +22,8 @@ export interface WalletState {
2222
const initialState: WalletState = {
2323
connected: false,
2424
isLoading: false,
25-
language: 'en',
26-
locale: defaultLocale.messages,
25+
locale: 'en',
26+
translations: defaultLocale.messages,
2727
forceReconnect: false,
2828
accounts: [],
2929
erc20TokenBalances: [],
@@ -37,12 +37,12 @@ export const walletSlice = createSlice({
3737
name: 'wallet',
3838
initialState,
3939
reducers: {
40-
setLanguage: (state, { payload }) => {
41-
state.language = payload;
42-
},
4340
setLocale: (state, { payload }) => {
4441
state.locale = payload;
4542
},
43+
setTranslations: (state, { payload }) => {
44+
state.translations = payload;
45+
},
4646
setProvider: (state, { payload }) => {
4747
state.provider = payload;
4848
},
@@ -128,7 +128,7 @@ export const {
128128
setTransactionDeploy,
129129
resetWallet,
130130
setProvider,
131-
setLanguage,
131+
setTranslations,
132132
setLocale,
133133
} = walletSlice.actions;
134134

0 commit comments

Comments
 (0)