Skip to content

Commit 2af2086

Browse files
authored
Merge pull request #1498 from Bilb/chore-replace-i18n-calls
chore: rename localize calls
2 parents 84695ca + 19dc9c2 commit 2af2086

File tree

179 files changed

+1000
-1384
lines changed

Some content is hidden

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

179 files changed

+1000
-1384
lines changed

about_preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { initializeRendererProcessLogger } = require('./ts/util/logger/renderer_p
1616

1717
initializeRendererProcessLogger();
1818

19-
window.i18n = setupI18n({
19+
setupI18n({
2020
crowdinLocale,
2121
});
2222

password_preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const { initializeRendererProcessLogger } = require('./ts/util/logger/renderer_p
1717

1818
initializeRendererProcessLogger();
1919

20-
window.i18n = setupI18n({
20+
setupI18n({
2121
crowdinLocale,
2222
});
2323

preload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const { initializeRendererProcessLogger } = require('./ts/util/logger/renderer_p
2323

2424
initializeRendererProcessLogger();
2525

26-
window.i18n = setupI18n({ crowdinLocale });
26+
setupI18n({ crowdinLocale });
2727

2828
let title = config.name;
2929
if (config.environment !== 'production') {

stylesheets/_modules.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@
298298
}
299299
}
300300

301-
302-
303301
// Module: Document List Item
304302

305303
.module-document-list-item {

tools/localization/regex.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ def get_localization_regex_list(string):
1111
fr"\{{ token: '{key}'(, args: {{.*}})? \}}",
1212
# This also captures the same group as `basic_object` but this is fine because basic_object shortcuts before reaching here if found.
1313
fr"{{\s+token: '{key}',?\s+(\s*args: {{[\S\s.]*}},)?\s+\}}",
14-
fr"window\.i18n\.(stripped|inEnglish|getRawMessage)\('{key}'(, {{[\S\s.]*}})?\)",
1514
fr"<I18n[\S\s.]*token=\{{?['\"]{key}['\"]\}}?",
1615
fr"<I18n[\S\s.]*token=[\S\s.]*{key}[\S\s.]*",
1716
fr"i18n\('{key}'\)",
1817
fr"i18n\('{key}'(, {{[\S\s.]*}})?\)",
19-
fr"i18n\.(stripped|inEnglish|getRawMessage)\('{key}'(, {{[\S\s.]*}})?\)",
2018
fr"window\?\.i18n\?\.\('{key}'(, {{[\S\s.]*}})?\)"
2119
]
2220

ts/components/AboutView.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { themeStore } from '../state/theme/store';
1010
import { SessionButton, SessionButtonType } from './basic/SessionButton';
1111
import { Localizer } from './basic/Localizer';
1212
import { CopyToClipboardButton } from './buttons';
13-
import { localize } from '../localization/localeTools';
13+
import { tr } from '../localization/localeTools';
1414

1515
const StyledContent = styled(Flex)`
1616
background-color: var(--background-primary-color);
@@ -60,18 +60,13 @@ export const AboutView = () => {
6060
}
6161

6262
const version = window.getVersion();
63-
const versionInfo = localize('updateVersion').withArgs({ version }).toString();
64-
const systemInfo = localize('systemInformationDesktop')
65-
.withArgs({
66-
information: window.getOSRelease(),
67-
})
68-
.toString();
69-
const commitInfo = localize('commitHashDesktop')
70-
.withArgs({
71-
hash: window.getCommitHash() || localize('unknown').toString(),
72-
})
73-
.toString();
74-
63+
const versionInfo = tr('updateVersion', { version });
64+
const systemInfo = tr('systemInformationDesktop', {
65+
information: window.getOSRelease(),
66+
});
67+
const commitInfo = tr('commitHashDesktop', {
68+
hash: window.getCommitHash() || tr('unknown'),
69+
});
7570
useEffect(() => {
7671
if (window.theme) {
7772
void switchThemeTo({

ts/components/EmptyMessageView.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Flex } from './basic/Flex';
66
import { Spacer2XL, SpacerXS } from './basic/Text';
77
import { Localizer } from './basic/Localizer';
88
import { useShowOnboardingAccountJustCreated } from '../state/selectors/settings';
9+
import { tr } from '../localization/localeTools';
910

1011
const StyledPlaceholder = styled(Flex)`
1112
background-color: var(--background-secondary-color);
@@ -87,7 +88,7 @@ export const EmptyMessageView = () => {
8788
<>
8889
<StyledPartyPopper src="images/party-popper.svg" alt="party popper emoji" />
8990
<Spacer2XL />
90-
<StyledHeading>{window.i18n('onboardingAccountCreated')}</StyledHeading>
91+
<StyledHeading>{tr('onboardingAccountCreated')}</StyledHeading>
9192
<StyledSessionWelcome color={'var(--renderer-span-primary-color)'}>
9293
<Localizer token="onboardingBubbleWelcomeToSession" args={{ emoji: '👋' }} />
9394
</StyledSessionWelcome>
@@ -109,10 +110,10 @@ export const EmptyMessageView = () => {
109110
<>
110111
<StyledHR />
111112
<StyledNoConversations data-testid="empty-conversation">
112-
{window.i18n('conversationsNone')}
113+
{tr('conversationsNone')}
113114
</StyledNoConversations>
114115
<SpacerXS />
115-
<StyledP style={{ width: '360px' }}>{window.i18n('onboardingHitThePlusButton')}</StyledP>
116+
<StyledP style={{ width: '360px' }}>{tr('onboardingHitThePlusButton')}</StyledP>
116117
</>
117118
) : null}
118119
</StyledPlaceholder>

ts/components/MemberListItem.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
} from '../webworker/workers/browser/libsession_worker_interface';
3434
import { assertUnreachable } from '../types/sqlSharedTypes';
3535
import { isUsAnySogsFromCache } from '../session/apis/open_group_api/sogsv3/knownBlindedkeys';
36-
import { localize } from '../localization/localeTools';
36+
import { tr } from '../localization/localeTools';
3737

3838
const AvatarContainer = styled.div`
3939
position: relative;
@@ -169,29 +169,29 @@ const StyledGroupStatusText = styled.span<{ isFailure: boolean }>`
169169
function localisedStatusFromMemberStatus(memberStatus: MemberStateGroupV2) {
170170
switch (memberStatus) {
171171
case 'INVITE_FAILED':
172-
return window.i18n('groupInviteFailed');
172+
return tr('groupInviteFailed');
173173
case 'INVITE_NOT_SENT':
174-
return window.i18n('groupInviteNotSent');
174+
return tr('groupInviteNotSent');
175175
case 'INVITE_SENDING':
176-
return window.i18n('groupInviteSending', { count: 1 });
176+
return tr('groupInviteSending', { count: 1 });
177177
case 'INVITE_SENT':
178-
return window.i18n('groupInviteSent');
178+
return tr('groupInviteSent');
179179
case 'INVITE_UNKNOWN': // fallback, hopefully won't happen in production
180-
return window.i18n('groupInviteStatusUnknown');
180+
return tr('groupInviteStatusUnknown');
181181
case 'PROMOTION_UNKNOWN': // fallback, hopefully won't happen in production
182-
return window.i18n('adminPromotionStatusUnknown');
182+
return tr('adminPromotionStatusUnknown');
183183
case 'REMOVED_UNKNOWN': // fallback, hopefully won't happen in production
184184
case 'REMOVED_MEMBER': // we want pending removal members at the end of the "invite" states
185185
case 'REMOVED_MEMBER_AND_MESSAGES':
186-
return window.i18n('groupPendingRemoval');
186+
return tr('groupPendingRemoval');
187187
case 'PROMOTION_FAILED':
188-
return window.i18n('adminPromotionFailed');
188+
return tr('adminPromotionFailed');
189189
case 'PROMOTION_NOT_SENT':
190-
return window.i18n('adminPromotionNotSent');
190+
return tr('adminPromotionNotSent');
191191
case 'PROMOTION_SENDING':
192-
return window.i18n('adminSendingPromotion', { count: 1 });
192+
return tr('adminSendingPromotion', { count: 1 });
193193
case 'PROMOTION_SENT':
194-
return window.i18n('adminPromotionSent');
194+
return tr('adminPromotionSent');
195195
case 'PROMOTION_ACCEPTED':
196196
return null; // no statuses for accepted state;
197197
case 'INVITE_ACCEPTED':
@@ -269,7 +269,7 @@ const ResendButton = ({ groupPk, pubkey }: { pubkey: PubkeyType; groupPk: GroupP
269269
dataTestId={'resend-invite-button'}
270270
buttonShape={SessionButtonShape.Square}
271271
buttonType={SessionButtonType.Solid}
272-
text={window.i18n('resend')}
272+
text={tr('resend')}
273273
disabled={resendButtonDisabled}
274274
onClick={async () => {
275275
const group = await UserGroupsWrapperActions.getGroup(groupPk);
@@ -311,7 +311,7 @@ const PromoteButton = ({ groupPk, pubkey }: { pubkey: PubkeyType; groupPk: Group
311311
buttonShape={SessionButtonShape.Square}
312312
buttonType={SessionButtonType.Solid}
313313
buttonColor={SessionButtonColor.Danger}
314-
text={window.i18n('promote')}
314+
text={tr('promote')}
315315
onClick={() => {
316316
void promoteUsersInGroup({
317317
groupPk,
@@ -342,7 +342,7 @@ export const MemberListItem = <T extends string>({
342342
}: MemberListItemProps<T>) => {
343343
const memberName = useNicknameOrProfileNameOrShortenedPubkey(pubkey);
344344
const isYou = isUsAnySogsFromCache(pubkey);
345-
const ourName = isYou ? localize('you').toString() : null;
345+
const ourName = isYou ? tr('you') : null;
346346
const shortPubkey = PubKey.shorten(pubkey);
347347
const nameSuffix =
348348
isPublic && inMentions && !isYou && memberName !== shortPubkey ? shortPubkey : '';

ts/components/SessionPasswordPrompt.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { SessionToastContainer } from './SessionToastContainer';
1212
import { SessionToast } from './basic/SessionToast';
1313
import { SessionSpinner } from './loading';
1414
import { Localizer } from './basic/Localizer';
15-
import { localize } from '../localization/localeTools';
15+
import { tr } from '../localization/localeTools';
1616
import {
1717
ModalBasicHeader,
1818
ModalActionsContainer,
@@ -58,16 +58,12 @@ function ClearDataViewButtons({ onCancel }: { onCancel: () => void }) {
5858
return (
5959
<ModalActionsContainer>
6060
<SessionButton
61-
text={localize('clearDevice').toString()}
61+
text={tr('clearDevice')}
6262
buttonColor={SessionButtonColor.Danger}
6363
buttonType={SessionButtonType.Simple}
6464
onClick={window.clearLocalData}
6565
/>
66-
<SessionButton
67-
text={localize('cancel').toString()}
68-
buttonType={SessionButtonType.Simple}
69-
onClick={onCancel}
70-
/>
66+
<SessionButton text={tr('cancel')} buttonType={SessionButtonType.Simple} onClick={onCancel} />
7167
</ModalActionsContainer>
7268
);
7369
}
@@ -93,15 +89,15 @@ function PasswordViewButtons({
9389
<ModalActionsContainer>
9490
{showResetElements && (
9591
<SessionButton
96-
text={localize('clearDevice').toString()}
92+
text={tr('clearDevice')}
9793
buttonColor={SessionButtonColor.Danger}
9894
buttonType={SessionButtonType.Simple}
9995
onClick={onShowClearDataView}
10096
/>
10197
)}
10298
{!loading && (
10399
<SessionButton
104-
text={showResetElements ? localize('tryAgain').toString() : localize('done').toString()}
100+
text={showResetElements ? tr('tryAgain') : tr('done')}
105101
buttonType={SessionButtonType.Simple}
106102
onClick={initLogin}
107103
disabled={loading}
@@ -148,7 +144,7 @@ const PasswordPrompt = ({
148144
}) => {
149145
return (
150146
<ShowHideSessionInput
151-
placeholder={localize('passwordEnter').toString()}
147+
placeholder={tr('passwordEnter')}
152148
onEnterPressed={onEnterPressed}
153149
onValueChanged={onPasswordChange}
154150
ariaLabel="password input"
@@ -194,9 +190,7 @@ const SessionPasswordPromptInner = () => {
194190
return (
195191
<SessionWrapperModal
196192
headerChildren={
197-
<ModalBasicHeader
198-
title={localize(clearDataView ? 'clearDevice' : 'passwordEnter').toString()}
199-
/>
193+
<ModalBasicHeader title={tr(clearDataView ? 'clearDevice' : 'passwordEnter')} />
200194
}
201195
$contentMinWidth={WrapperModalWidth.narrow}
202196
buttonChildren={

ts/components/SessionQRCode.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { THEME_GLOBALS } from '../themes/globals';
55
import { renderQRCode } from '../util/qrCodes';
66
import { AnimatedFlex } from './basic/Flex';
77
import { SessionIconType } from './icon';
8+
import { tr } from '../localization/localeTools';
89

910
// AnimatedFlex because we fade in the QR code a flicker on first render
1011
const StyledQRView = styled(AnimatedFlex)<{
@@ -113,7 +114,7 @@ export function SessionQRCode(props: SessionQRCodeProps) {
113114
$alignItems="center"
114115
size={size}
115116
id={id}
116-
title={window.i18n('download')}
117+
title={tr('download')}
117118
aria-label={ariaLabel || 'QR code'}
118119
onClick={(event: MouseEvent<HTMLDivElement>) => {
119120
event.preventDefault();

0 commit comments

Comments
 (0)