Skip to content

Commit 20c4889

Browse files
authored
feat: add translation building capability to Streami18n and useNotifications hook (#2719)
1 parent 37264db commit 20c4889

File tree

99 files changed

+1146
-551
lines changed

Some content is hidden

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

99 files changed

+1146
-551
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"emoji-regex": "^9.2.0",
111111
"fix-webm-duration": "^1.0.5",
112112
"hast-util-find-and-replace": "^5.0.1",
113-
"i18next": "^21.6.14",
113+
"i18next": "^25.2.1",
114114
"linkifyjs": "^4.1.0",
115115
"lodash.debounce": "^4.0.8",
116116
"lodash.defaultsdeep": "^4.6.1",
@@ -226,7 +226,7 @@
226226
"eslint-plugin-sort-destructure-keys": "^2.0.0",
227227
"globals": "^15.13.0",
228228
"husky": "^8.0.3",
229-
"i18next-parser": "^6.0.0",
229+
"i18next-parser": "^9.3.0",
230230
"jest": "^29.7.0",
231231
"jest-axe": "^8.0.0",
232232
"jest-environment-jsdom": "^29.7.0",

src/components/Attachment/AttachmentActions.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const UnMemoizedAttachmentActions = (props: AttachmentActionsProps) => {
3838
key={`${id}-${action.value}`}
3939
onClick={(event) => handleActionClick(event, action.name, action.value)}
4040
>
41-
{action.text ? t<string>(action.text) : null}
41+
{action.text ? t(action.text) : null}
4242
</button>
4343
))}
4444
</div>

src/components/Attachment/Card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const UnableToRenderCard = ({ type }: { type?: CardProps['type'] }) => {
3434
>
3535
<div className='str-chat__message-attachment-card--content'>
3636
<div className='str-chat__message-attachment-card--text'>
37-
{t<string>('this content could not be displayed')}
37+
{t('this content could not be displayed')}
3838
</div>
3939
</div>
4040
</div>

src/components/Attachment/UnsupportedAttachment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const UnsupportedAttachment = ({ attachment }: UnsupportedAttachmentProps
2121
className='str-chat__message-attachment-unsupported__title'
2222
data-testid='unsupported-attachment-title'
2323
>
24-
{attachment.title || t<string>('Unsupported attachment')}
24+
{attachment.title || t('Unsupported attachment')}
2525
</div>
2626
</div>
2727
</div>

src/components/Attachment/VoiceRecording.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const VoiceRecordingPlayer = ({
2828
asset_url,
2929
duration = 0,
3030
mime_type,
31-
title = t<string>('Voice message'),
31+
title = t('Voice message'),
3232
waveform_data,
3333
} = attachment;
3434

@@ -100,7 +100,7 @@ export type QuotedVoiceRecordingProps = Pick<VoiceRecordingProps, 'attachment'>;
100100

101101
export const QuotedVoiceRecording = ({ attachment }: QuotedVoiceRecordingProps) => {
102102
const { t } = useTranslationContext();
103-
const title = attachment.title || t<string>('Voice message');
103+
const title = attachment.title || t('Voice message');
104104
return (
105105
<div className={rootClassName} data-testid='quoted-voice-recording-widget'>
106106
<div className='str-chat__message-attachment__voice-recording-widget__metadata'>

src/components/Attachment/hooks/useAudioController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export const useAudioController = ({
125125
audioElement.addEventListener('ended', handleEnded);
126126

127127
const handleError = () => {
128-
addNotification(t<string>('Error reproducing the recording'), 'error');
128+
addNotification(t('Error reproducing the recording'), 'error');
129129
setIsPlaying(false);
130130
};
131131
audioElement.addEventListener('error', handleError);

src/components/Channel/Channel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ const ChannelInner = (
397397
document.title = originalTitle.current;
398398
}
399399
} catch (e) {
400-
console.error(t<string>('Failed to mark channel as read'));
400+
console.error(t('Failed to mark channel as read'));
401401
}
402402
},
403403
500,
@@ -1339,7 +1339,7 @@ const ChannelInner = (
13391339
if (!channel.watch) {
13401340
return (
13411341
<ChannelContainer>
1342-
<div>{t<string>('Channel Missing')}</div>
1342+
<div>{t('Channel Missing')}</div>
13431343
</ChannelContainer>
13441344
);
13451345
}

src/components/ChannelHeader/ChannelHeader.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ export const ChannelHeader = (props: ChannelHeaderProps) => {
6363
<p className='str-chat__channel-header-title'>
6464
{displayTitle}{' '}
6565
{live && (
66-
<span className='str-chat__header-livestream-livelabel'>
67-
{t<string>('live')}
68-
</span>
66+
<span className='str-chat__header-livestream-livelabel'>{t('live')}</span>
6967
)}
7068
</p>
7169
{subtitle && <p className='str-chat__channel-header-subtitle'>{subtitle}</p>}
@@ -78,7 +76,7 @@ export const ChannelHeader = (props: ChannelHeaderProps) => {
7876
,{' '}
7977
</>
8078
)}
81-
{t<string>('{{ watcherCount }} online', { watcherCount: watcher_count })}
79+
{t('{{ watcherCount }} online', { watcherCount: watcher_count })}
8280
</p>
8381
</div>
8482
</div>

src/components/ChannelHeader/icons.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const MenuIcon = ({ title }: { title?: string }) => {
77

88
return (
99
<svg data-testid='menu-icon' viewBox='0 0 448 512' xmlns='http://www.w3.org/2000/svg'>
10-
<title>{title ?? t<string>('Menu')}</title>
10+
<title>{title ?? t('Menu')}</title>
1111
<path
1212
d='M0 88C0 74.75 10.75 64 24 64H424C437.3 64 448 74.75 448 88C448 101.3 437.3 112 424 112H24C10.75 112 0 101.3 0 88zM0 248C0 234.7 10.75 224 24 224H424C437.3 224 448 234.7 448 248C448 261.3 437.3 272 424 272H24C10.75 272 0 261.3 0 248zM424 432H24C10.75 432 0 421.3 0 408C0 394.7 10.75 384 24 384H424C437.3 384 448 394.7 448 408C448 421.3 437.3 432 424 432z'
1313
fill='currentColor'

src/components/ChannelPreview/utils.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ export const getLatestMessagePreview = (
3838
const poll = latestMessage?.poll;
3939

4040
if (!latestMessage) {
41-
return t<string>('Nothing yet...');
41+
return t('Nothing yet...');
4242
}
4343

4444
if (latestMessage.deleted_at) {
45-
return t<string>('Message deleted');
45+
return t('Message deleted');
4646
}
4747

4848
if (poll) {
4949
if (!poll.vote_count) {
5050
const createdBy =
5151
poll.created_by?.id === channel.getClient().userID
52-
? t<string>('You')
53-
: (poll.created_by?.name ?? t<string>('Poll'));
54-
return t<string>('📊 {{createdBy}} created: {{ pollName}}', {
52+
? t('You')
53+
: (poll.created_by?.name ?? t('Poll'));
54+
return t('📊 {{createdBy}} created: {{ pollName}}', {
5555
createdBy,
5656
pollName: poll.name,
5757
});
@@ -63,12 +63,12 @@ export const getLatestMessagePreview = (
6363
latestVote && poll.options.find((opt) => opt.id === latestVote.option_id);
6464

6565
if (option && latestVote) {
66-
return t<string>('📊 {{votedBy}} voted: {{pollOptionText}}', {
66+
return t('📊 {{votedBy}} voted: {{pollOptionText}}', {
6767
pollOptionText: option.text,
6868
votedBy:
6969
latestVote?.user?.id === channel.getClient().userID
70-
? t<string>('You')
71-
: (latestVote.user?.name ?? t<string>('Poll')),
70+
? t('You')
71+
: (latestVote.user?.name ?? t('Poll')),
7272
});
7373
}
7474
}
@@ -85,10 +85,10 @@ export const getLatestMessagePreview = (
8585
}
8686

8787
if (latestMessage.attachments?.length) {
88-
return t<string>('🏙 Attachment...');
88+
return t('🏙 Attachment...');
8989
}
9090

91-
return t<string>('Empty message...');
91+
return t('Empty message...');
9292
};
9393

9494
export type GroupChannelDisplayInfo = { image?: string; name?: string }[];

0 commit comments

Comments
 (0)