Skip to content

Commit 7e47281

Browse files
committed
Remove overcomplicated type check in translations
1 parent 2f7dc24 commit 7e47281

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

packages/browser-wallet/src/popup/popupX/pages/PrivateKey/PrivateKey.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Page from '@popup/popupX/shared/Page';
33
import { useTranslation } from 'react-i18next';
4+
import i18n from '@popup/shell/i18n/i18n';
45
import Text from '@popup/popupX/shared/Text';
56
import Card from '@popup/popupX/shared/Card';
67
import Button from '@popup/popupX/shared/Button';
@@ -134,7 +135,7 @@ function Loader() {
134135
}
135136

136137
export default withPasswordProtected(Loader, {
137-
headingKey: 'privateKey.accountPrivateKey',
138-
pageInfoKey: 'privateKey.passwordDescription',
139-
submitKey: 'privateKey.showPrivateKey',
138+
headingText: i18n.t('x:privateKey.accountPrivateKey'),
139+
pageInfoText: i18n.t('x:privateKey.passwordDescription'),
140+
submitText: i18n.t('x:privateKey.showPrivateKey'),
140141
});

packages/browser-wallet/src/popup/popupX/pages/SeedPhrase/SeedPhrase.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Button from '@popup/popupX/shared/Button';
33
import { useTranslation } from 'react-i18next';
4+
import i18n from '@popup/shell/i18n';
45
import Page from '@popup/popupX/shared/Page';
56
import Text from '@popup/popupX/shared/Text';
67
import Card from '@popup/popupX/shared/Card';
@@ -50,7 +51,7 @@ function SeedPhrase() {
5051
}
5152

5253
export default withPasswordProtected(SeedPhrase, {
53-
headingKey: 'seedPhrase.seedPhrase',
54-
pageInfoKey: 'seedPhrase.passwordDescription',
55-
submitKey: 'seedPhrase.showSeedPhrase',
54+
headingText: i18n.t('x:seedPhrase.seedPhrase'),
55+
pageInfoText: i18n.t('x:seedPhrase.passwordDescription'),
56+
submitText: i18n.t('x:seedPhrase.showSeedPhrase'),
5657
});

packages/browser-wallet/src/popup/popupX/shared/PasswordProtect/PasswordProtect.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import FormPassword from '@popup/popupX/shared/Form/Password';
99
import Form from '@popup/popupX/shared/Form/Form';
1010
import { sessionPasscodeAtom } from '@popup/store/settings';
1111
import { useForm } from '@popup/shared/Form';
12-
import { TranslationKeyX } from '@popup/shell/i18n/i18n';
1312

1413
type FormValues = {
1514
currentPasscode: string;
1615
};
1716

1817
export type PasswordProtectConfigType = {
19-
headingKey: TranslationKeyX;
20-
pageInfoKey: TranslationKeyX;
21-
submitKey: TranslationKeyX;
18+
headingText: string;
19+
pageInfoText: string;
20+
submitText: string;
2221
};
2322

2423
type PasswordProtectProps = {
@@ -28,10 +27,8 @@ type PasswordProtectProps = {
2827

2928
export default function PasswordProtect({
3029
setPasswordConfirmed,
31-
config: { headingKey, pageInfoKey, submitKey },
30+
config: { headingText, pageInfoText, submitText },
3231
}: PasswordProtectProps) {
33-
const { t: tUse } = useTranslation('x');
34-
const t = (key: TranslationKeyX) => tUse(key) as unknown as string;
3532
const { t: tPasscode } = useTranslation('x', { keyPrefix: 'sharedX.form.password' });
3633
const passcode = useAtomValue(sessionPasscodeAtom);
3734
const form = useForm<FormValues>();
@@ -46,9 +43,9 @@ export default function PasswordProtect({
4643

4744
return (
4845
<Page className="confirm-password-x">
49-
<Page.Top heading={t(headingKey)} />
46+
<Page.Top heading={headingText} />
5047
<Page.Main>
51-
<Text.MainRegular>{t(pageInfoKey)}</Text.MainRegular>
48+
<Text.MainRegular>{pageInfoText}</Text.MainRegular>
5249
<Form id="confirm-password-form" onSubmit={handleSubmit} formMethods={form}>
5350
{(f) => {
5451
return (
@@ -70,7 +67,7 @@ export default function PasswordProtect({
7067
<Button.Main
7168
form="confirm-password-form"
7269
type="submit"
73-
label={t(submitKey)}
70+
label={submitText}
7471
disabled={form.formState.isSubmitting}
7572
/>
7673
</Page.Footer>

packages/browser-wallet/src/popup/popupX/shared/utils/typescriptHelpers.ts

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

packages/browser-wallet/src/popup/shell/i18n/i18n.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import i18n from 'i18next';
33
import { initReactI18next } from 'react-i18next';
44
import LanguageDetector from 'i18next-browser-languagedetector';
55
import countries from 'i18n-iso-countries';
6-
import { ObjectPath } from '@popup/popupX/shared/utils/typescriptHelpers';
76

87
import en from './locales/en';
98
import da from './locales/da';
109

1110
countries.registerLocale(require('i18n-iso-countries/langs/en.json'));
1211
countries.registerLocale(require('i18n-iso-countries/langs/da.json'));
1312

14-
export type TranslationKeyX = ObjectPath<typeof en.x>;
1513
export const defaultNS: keyof typeof en = 'shared';
1614
const ns: Array<keyof typeof en> = Object.keys(en) as Array<keyof typeof en>;
1715

0 commit comments

Comments
 (0)