Skip to content

Commit 279c920

Browse files
committed
i18n: extract auth strings into the lang file
1 parent ef4c854 commit 279c920

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

app/src/__tests__/components/loop/LoopPage.spec.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('LoopPage component', () => {
7474
const { getByText } = render();
7575
expect(getByText('Loop')).toBeInTheDocument();
7676
fireEvent.click(getByText('Loop'));
77-
expect(getByText('Loop out')).toBeInTheDocument();
78-
expect(getByText('Loop in')).toBeInTheDocument();
77+
expect(getByText('Loop Out')).toBeInTheDocument();
78+
expect(getByText('Loop In')).toBeInTheDocument();
7979
});
8080

8181
it('should display swap wizard when Loop out is clicked', async () => {
@@ -85,7 +85,7 @@ describe('LoopPage component', () => {
8585
store.channelStore.sortedChannels.slice(0, 3).forEach(c => {
8686
store.buildSwapStore.toggleSelectedChannel(c.chanId);
8787
});
88-
fireEvent.click(getByText('Loop out'));
88+
fireEvent.click(getByText('Loop Out'));
8989
expect(getByText('Step 1 of 2')).toBeInTheDocument();
9090
});
9191

@@ -96,7 +96,7 @@ describe('LoopPage component', () => {
9696
store.channelStore.sortedChannels.slice(0, 1).forEach(c => {
9797
store.buildSwapStore.toggleSelectedChannel(c.chanId);
9898
});
99-
fireEvent.click(getByText('Loop in'));
99+
fireEvent.click(getByText('Loop In'));
100100
expect(getByText('Step 1 of 2')).toBeInTheDocument();
101101
});
102102

@@ -107,7 +107,7 @@ describe('LoopPage component', () => {
107107
store.channelStore.sortedChannels.slice(0, 1).forEach(c => {
108108
store.buildSwapStore.toggleSelectedChannel(c.chanId);
109109
});
110-
fireEvent.click(getByText('Loop in'));
110+
fireEvent.click(getByText('Loop In'));
111111
expect(getByText('Step 1 of 2')).toBeInTheDocument();
112112
fireEvent.click(getByText('arrow-left.svg'));
113113
expect(getByText('Loop History')).toBeInTheDocument();
@@ -120,7 +120,7 @@ describe('LoopPage component', () => {
120120
store.channelStore.sortedChannels.slice(0, 3).forEach(c => {
121121
store.buildSwapStore.toggleSelectedChannel(c.chanId);
122122
});
123-
fireEvent.click(getByText('Loop out'));
123+
fireEvent.click(getByText('Loop Out'));
124124
expect(getByText('Step 1 of 2')).toBeInTheDocument();
125125
fireEvent.click(getByText('Next'));
126126
expect(getByText('Step 2 of 2')).toBeInTheDocument();
@@ -141,7 +141,7 @@ describe('LoopPage component', () => {
141141
store.channelStore.sortedChannels.slice(0, 3).forEach(c => {
142142
store.buildSwapStore.toggleSelectedChannel(c.chanId);
143143
});
144-
fireEvent.click(getByText('Loop out'));
144+
fireEvent.click(getByText('Loop Out'));
145145
expect(getByText('Step 1 of 2')).toBeInTheDocument();
146146
fireEvent.click(getByText('Next'));
147147
expect(getByText('Step 2 of 2')).toBeInTheDocument();

app/src/components/loop/LoopActions.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const Styled = {
3636
margin-left: 20px;
3737
font-size: ${props => props.theme.sizes.s};
3838
color: ${props => props.theme.colors.gray};
39-
/* font-style: italic; */
4039
`,
4140
};
4241

@@ -64,7 +63,7 @@ const LoopActions: React.FC = () => {
6463
borderless
6564
onClick={handleLoopOut}
6665
>
67-
Loop out
66+
{l('common.loopOut')}
6867
</Button>
6968
<Button
7069
primary={
@@ -74,15 +73,15 @@ const LoopActions: React.FC = () => {
7473
onClick={handleLoopIn}
7574
disabled={!buildSwapStore.loopInAllowed}
7675
>
77-
Loop in
76+
{l('common.loopIn')}
7877
</Button>
7978
</ActionBar>
8079
{!buildSwapStore.loopInAllowed && <Note>{l('loopInNote')}</Note>}
8180
</Actions>
8281
) : (
8382
<Button onClick={buildSwapStore.startSwap}>
8483
<Refresh />
85-
Loop
84+
{l('common.loop')}
8685
</Button>
8786
)}
8887
</Wrapper>

app/src/i18n/locales/en-US.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{
2+
"common.loop": "Loop",
3+
"common.loopIn": "Loop In",
4+
"common.loopOut": "Loop Out",
25
"enums.BalanceMode.receive": "Receiving",
36
"enums.BalanceMode.send": "Sending",
47
"enums.BalanceMode.routing": "Routing",
@@ -64,6 +67,8 @@
6467
"cmps.settings.GeneralSettings.pageTitle": "Settings",
6568
"cmps.settings.UnitSettings.pageTitle": "Bitcoin Unit",
6669
"cmps.settings.UnitSettings.backText": "Settings",
70+
"stores.authStore.emptyPassErr": "oops, password is required",
71+
"stores.authStore.invalidPassErr": "oops, that password is incorrect",
6772
"stores.uiStore.authErrorTitle": "Your session has expired",
6873
"stores.uiStore.authErrorMsg": "Please enter you password to continue"
6974
}

app/src/store/stores/authStore.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { action, observable } from 'mobx';
2+
import { prefixTranslation } from 'util/translate';
23
import { Store } from 'store';
34

5+
const { l } = prefixTranslation('stores.authStore');
6+
47
export default class AuthStore {
58
private _store: Store;
69

@@ -32,7 +35,7 @@ export default class AuthStore {
3235
@action.bound
3336
async login(password: string) {
3437
this._store.log.info('attempting to login with password');
35-
if (!password) throw new Error('oops, password is required');
38+
if (!password) throw new Error(l('emptyPassErr'));
3639

3740
// encode the password and update the store
3841
const encoded = Buffer.from(`${password}:${password}`).toString('base64');
@@ -46,7 +49,7 @@ export default class AuthStore {
4649
// clear the credentials if incorrect
4750
this.setCredentials('');
4851
this._store.log.error('incorrect credentials');
49-
throw new Error('oops, that password is incorrect');
52+
throw new Error(l('invalidPassErr'));
5053
}
5154
}
5255

0 commit comments

Comments
 (0)