Skip to content

Commit 1d6a74b

Browse files
committed
chore: removed i18n() and i18n.stripped() calls
1 parent ebab124 commit 1d6a74b

File tree

79 files changed

+393
-453
lines changed

Some content is hidden

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

79 files changed

+393
-453
lines changed

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ 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.]*}})?\)",
14+
fr"window\.i18n\.(getRawMessage)\('{key}'(, {{[\S\s.]*}})?\)",
1515
fr"<I18n[\S\s.]*token=\{{?['\"]{key}['\"]\}}?",
1616
fr"<I18n[\S\s.]*token=[\S\s.]*{key}[\S\s.]*",
1717
fr"i18n\('{key}'\)",
1818
fr"i18n\('{key}'(, {{[\S\s.]*}})?\)",
19-
fr"i18n\.(stripped|inEnglish|getRawMessage)\('{key}'(, {{[\S\s.]*}})?\)",
19+
fr"i18n\.(getRawMessage)\('{key}'(, {{[\S\s.]*}})?\)",
2020
fr"window\?\.i18n\?\.\('{key}'(, {{[\S\s.]*}})?\)"
2121
]
2222

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: 14 additions & 14 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 { localize, 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,

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();

ts/components/basic/YourSessionIDPill.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled from 'styled-components';
22
import type { SessionDataTestId } from 'react';
3+
import { tr } from '../../localization/localeTools';
34

45
const StyledPillDividerLine = styled.div`
56
border-bottom: 1px solid var(--border-color);
@@ -27,7 +28,7 @@ export const YourSessionIDPill = () => {
2728
return (
2829
<StyledPillDivider>
2930
<StyledPillDividerLine />
30-
<StyledPillSpan>{window.i18n('accountIdYours')}</StyledPillSpan>
31+
<StyledPillSpan>{tr('accountIdYours')}</StyledPillSpan>
3132
<StyledPillDividerLine />
3233
</StyledPillDivider>
3334
);

ts/components/buttons/CopyToClipboardButton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SessionButton, SessionButtonProps } from '../basic/SessionButton';
77
import { SessionIconButtonProps, SessionLucideIconButton } from '../icon/SessionIconButton';
88
import { LUCIDE_ICONS_UNICODE } from '../icon/lucide';
99
import type { SessionIconSize } from '../icon';
10+
import { tr } from '../../localization/localeTools';
1011

1112
type CopyProps = {
1213
copyContent?: string;
@@ -45,7 +46,7 @@ export const CopyToClipboardButton = (props: CopyToClipboardButtonProps) => {
4546
<SessionButton
4647
aria-label={'copy to clipboard button'}
4748
{...props}
48-
text={!isEmpty(text) ? text : copied ? window.i18n('copied') : window.i18n('copy')}
49+
text={!isEmpty(text) ? text : copied ? tr('copied') : tr('copy')}
4950
onClick={onClick}
5051
/>
5152
);

ts/components/calling/InConversationCallContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { CallWindowControls } from './CallButtons';
2222

2323
import { useFormattedDuration } from '../../hooks/useFormattedDuration';
2424
import { SessionSpinner } from '../loading';
25+
import { tr } from '../../localization/localeTools';
2526

2627
const VideoContainer = styled.div`
2728
height: 100%;
@@ -75,7 +76,7 @@ const StyledCenteredLabel = styled.div`
7576
const RingingLabel = () => {
7677
const ongoingCallWithFocusedIsRinging = useSelector(getCallWithFocusedConvoIsOffering);
7778

78-
const modulatedStr = useModuloWithTripleDots(window.i18n('callsRinging'), 3, 1000);
79+
const modulatedStr = useModuloWithTripleDots(tr('callsRinging'), 3, 1000);
7980
if (!ongoingCallWithFocusedIsRinging) {
8081
return null;
8182
}
@@ -85,7 +86,7 @@ const RingingLabel = () => {
8586
const ConnectingLabel = () => {
8687
const ongoingCallWithFocusedIsConnecting = useSelector(getCallWithFocusedConvosIsConnecting);
8788

88-
const modulatedStr = useModuloWithTripleDots(window.i18n('callsConnecting'), 3, 1000);
89+
const modulatedStr = useModuloWithTripleDots(tr('callsConnecting'), 3, 1000);
8990

9091
if (!ongoingCallWithFocusedIsConnecting) {
9192
return null;

ts/components/conversation/MessageRequestButtons.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ConversationOutgoingRequestExplanation,
1818
} from './SubtleNotification';
1919
import { NetworkTime } from '../../util/NetworkTime';
20+
import { tr } from '../../localization/localeTools';
2021

2122
const MessageRequestContainer = styled.div`
2223
display: flex;
@@ -99,7 +100,7 @@ export const ConversationMessageRequestButtons = () => {
99100
<ConversationBannerRow>
100101
<SessionButton
101102
buttonColor={SessionButtonColor.PrimaryDark}
102-
text={window.i18n('accept')}
103+
text={tr('accept')}
103104
onClick={() => {
104105
void handleAcceptConversationRequest({
105106
convoId: selectedConvoId,
@@ -110,7 +111,7 @@ export const ConversationMessageRequestButtons = () => {
110111
/>
111112
<SessionButton
112113
buttonColor={SessionButtonColor.Danger}
113-
text={window.i18n('delete')}
114+
text={tr('delete')}
114115
onClick={() => {
115116
handleDeclineConversationRequest(selectedConvoId, selectedConvoId, convoOrigin);
116117
}}
@@ -136,7 +137,7 @@ export const ConversationMessageRequestButtons = () => {
136137
}}
137138
data-testid="decline-and-block-message-request"
138139
>
139-
{window.i18n('block')}
140+
{tr('block')}
140141
</StyledBlockUserText>
141142
) : null}
142143
</>

ts/components/conversation/SessionLastSeenIndicator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useSelector } from 'react-redux';
33
import styled from 'styled-components';
44
import { useScrollToLoadedMessage } from '../../contexts/ScrollToLoadedMessage';
55
import { getQuotedMessageToAnimate } from '../../state/selectors/conversations';
6+
import { tr } from '../../localization/localeTools';
67

78
const LastSeenBar = styled.div`
89
height: 2px;
@@ -73,7 +74,7 @@ export const SessionLastSeenIndicator = (props: {
7374
return (
7475
<LastSeenBarContainer id="unread-indicator">
7576
<LastSeenBar />
76-
<LastSeenText>{window.i18n('messageUnread')}</LastSeenText>
77+
<LastSeenText>{tr('messageUnread')}</LastSeenText>
7778

7879
<LastSeenBar />
7980
</LastSeenBarContainer>

0 commit comments

Comments
 (0)