Skip to content

Commit ac36d24

Browse files
committed
Added multi language support
Signed-off-by: AndrzejM <[email protected]>
1 parent 8c23132 commit ac36d24

37 files changed

+1637
-325
lines changed

.i18nrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"translations": ["translations/pl.json"]
3+
}

public/pages/Channels/Channels.tsx

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import MDSEnabledComponent, {
4343
isDataSourceChanged,
4444
isDataSourceError,
4545
} from '../../components/MDSEnabledComponent/MDSEnabledComponent';
46+
import { i18n } from '@osd/i18n';
4647

4748
interface ChannelsProps extends RouteComponentProps, DataSourceMenuProperties {
4849
notificationService: NotificationService;
@@ -76,7 +77,10 @@ export class Channels extends MDSEnabledComponent<ChannelsProps, ChannelsState>
7677
this.columns = [
7778
{
7879
field: 'name',
79-
name: 'Name',
80+
name: i18n.translate('notification.notificationChannels.notificationName', {
81+
defaultMessage:
82+
'Name',
83+
}),
8084
sortable: true,
8185
truncateText: true,
8286
render: (name: string, item: ChannelItemType) => (
@@ -87,24 +91,43 @@ export class Channels extends MDSEnabledComponent<ChannelsProps, ChannelsState>
8791
},
8892
{
8993
field: 'is_enabled',
90-
name: 'Notification status',
94+
name: i18n.translate('notification.notificationChannels.notificationStatus', {
95+
defaultMessage:
96+
'Notification status',
97+
}),
9198
sortable: true,
9299
render: (enabled: boolean) => {
93100
const color = enabled ? 'success' : 'subdued';
94-
const label = enabled ? 'Active' : 'Muted';
101+
const label = enabled ? i18n.translate('notification.notificationChannels.channelUnMuted', {
102+
defaultMessage:
103+
'Active',
104+
})
105+
: i18n.translate('notification.notificationChannels.channelMuted', {
106+
defaultMessage:
107+
'Muted',
108+
})
109+
;
110+
95111
return <EuiHealth color={color}>{label}</EuiHealth>;
96112
},
97113
},
98114
{
99115
field: 'config_type',
100-
name: 'Type',
116+
name: i18n.translate('notification.notificationChannels.notificationType', {
117+
defaultMessage:
118+
'Type',
119+
}),
120+
101121
sortable: true,
102122
truncateText: false,
103123
render: (type: string) => _.get(CHANNEL_TYPE, type, '-'),
104124
},
105125
{
106126
field: 'description',
107-
name: 'Description',
127+
name: i18n.translate('notification.notificationChannels.notificationDescription', {
128+
defaultMessage:
129+
'Description',
130+
}),
108131
sortable: true,
109132
truncateText: true,
110133
render: (description: string) => description || '-',
@@ -239,15 +262,21 @@ export class Channels extends MDSEnabledComponent<ChannelsProps, ChannelsState>
239262
{
240263
component: (
241264
<EuiButton fill href={`#${ROUTES.CREATE_CHANNEL}`}>
242-
Create channel
265+
{i18n.translate('notification.notificationChannels.newChannel', {
266+
defaultMessage:
267+
'Create channel',
268+
})}
243269
</EuiButton>
244270
),
245271
},
246272
]}
247273
/>
248274
}
249275
bodyStyles={{ padding: 'initial' }}
250-
title="Channels"
276+
title={i18n.translate('notification.notificationChannels.Title', {
277+
defaultMessage:
278+
"Channels",
279+
})}
251280
titleSize="m"
252281
total={this.state.total}
253282
>
@@ -266,11 +295,25 @@ export class Channels extends MDSEnabledComponent<ChannelsProps, ChannelsState>
266295
selection={selection}
267296
noItemsMessage={
268297
<EuiEmptyPrompt
269-
title={<h2>No channels to display</h2>}
270-
body="To send or receive notifications, you will need to create a notification channel."
298+
title={<h2>
299+
{i18n.translate('notification.notificationChannels.notificationNoChannelsToDisplay', {
300+
defaultMessage:
301+
'No channels to display',
302+
})}
303+
</h2>}
304+
body={
305+
i18n.translate('notification.notificationChannels.NotificationNoChannelsToDisplayDesc', {
306+
defaultMessage:
307+
"To send or receive notifications, you will need to create a notification channel.",
308+
})}
309+
271310
actions={
272311
<EuiButton href={`#${ROUTES.CREATE_CHANNEL}`}>
273-
Create channel
312+
{i18n.translate('notification.notificationChannels.createChannel', {
313+
defaultMessage:
314+
'Create channel',
315+
})}
316+
274317
</EuiButton>
275318
}
276319
/>

public/pages/Channels/components/ChannelActions.tsx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ServicesContext } from '../../../services';
1313
import { ROUTES } from '../../../utils/constants';
1414
import { DeleteChannelModal } from './modals/DeleteChannelModal';
1515
import { MuteChannelModal } from './modals/MuteChannelModal';
16+
import { i18n } from '@osd/i18n';
1617

1718
interface ChannelActionsParams {
1819
label: string;
@@ -38,39 +39,59 @@ export function ChannelActions(props: ChannelActionsProps) {
3839

3940
const actions: ChannelActionsParams[] = [
4041
{
41-
label: 'Edit',
42+
label: i18n.translate('notification.notificationChannels.editToken', {
43+
defaultMessage:
44+
'Edit',
45+
}),
4246
disabled: props.selected.length !== 1,
4347
href: `#${ROUTES.EDIT_CHANNEL}/${props.selected[0]?.config_id}`,
4448
},
4549
{
46-
label: 'Delete',
50+
label: i18n.translate('notification.notificationChannels.deleteToken', {
51+
defaultMessage:
52+
'Delete',
53+
}),
4754
disabled: props.selected.length === 0,
4855
modal: DeleteChannelModal,
4956
modalParams: { refresh: props.refresh },
5057
},
5158
{
52-
label: 'Mute',
59+
label: i18n.translate('notification.notificationChannels.actionMute', {
60+
defaultMessage:
61+
'Mute',
62+
}),
5363
disabled: props.selected.length !== 1 || !props.selected[0].is_enabled,
5464
modal: MuteChannelModal,
5565
modalParams: { refresh: props.refresh, setSelected: props.setSelected },
5666
},
5767
{
58-
label: 'Unmute',
68+
label: i18n.translate('notification.notificationChannels.actionUnmute', {
69+
defaultMessage:
70+
'Unmute',
71+
}),
5972
disabled: props.selected.length !== 1 || props.selected[0].is_enabled,
6073
action: async () => {
6174
const channel = { ...props.selected[0], is_enabled: true };
6275
servicesContext.notificationService
6376
.updateConfig(channel.config_id, channel)
6477
.then((resp) => {
6578
coreContext.notifications.toasts.addSuccess(
66-
`Channel ${channel.name} successfully unmuted.`
79+
i18n.translate('notification.notificationChannels.channelUnmutedSuccess', {
80+
defaultMessage:
81+
`Channel ${channel.name} successfully unmuted.`,
82+
values:{name:channel.name}
83+
})
84+
6785
);
6886
props.setSelected([channel]);
6987
setTimeout(() => props.refresh(), SERVER_DELAY);
7088
})
7189
.catch((error) => {
7290
coreContext.notifications.toasts.addError(error?.body || error, {
73-
title: 'Failed to unmute channel',
91+
title: i18n.translate('notification.notificationChannels.unmuteChannelErr', {
92+
defaultMessage:
93+
'Failed to unmute channel',
94+
}),
7495
});
7596
});
7697
},
@@ -89,7 +110,10 @@ export function ChannelActions(props: ChannelActionsProps) {
89110
disabled={props.selected.length === 0}
90111
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
91112
>
92-
Actions
113+
{i18n.translate('notification.notificationChannels.channelsActions', {
114+
defaultMessage:
115+
'Actions',
116+
})}
93117
</EuiButton>
94118
}
95119
isOpen={isPopoverOpen}

public/pages/Channels/components/ChannelControls.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
} from '../../../../common/constants';
2020
import { MainContext } from '../../Main/Main';
2121
import { ChannelFiltersType } from '../types';
22+
import { i18n } from '@osd/i18n';
2223

2324
interface ChannelControlsProps {
2425
onSearchChange: (search: string) => void;
@@ -30,8 +31,14 @@ export const ChannelControls = (props: ChannelControlsProps) => {
3031
const mainStateContext = useContext(MainContext)!;
3132
const [isStatePopoverOpen, setIsStatePopoverOpen] = useState(false);
3233
const [stateItems, setStateItems] = useState([
33-
{ field: 'true', display: 'Active', checked: 'off' },
34-
{ field: 'false', display: 'Muted', checked: 'off' },
34+
{ field: 'true', display: i18n.translate('notification.notificationChannels.channelUnMuted', {
35+
defaultMessage:
36+
'Active',
37+
}), checked: 'off' },
38+
{ field: 'false', display: i18n.translate('notification.notificationChannels.channelMuted', {
39+
defaultMessage:
40+
'Muted',
41+
}), checked: 'off' },
3542
]);
3643
const [isTypePopoverOpen, setIsTypePopoverOpen] = useState(false);
3744
const [typeItems, setTypeItems] = useState(
@@ -100,7 +107,10 @@ export const ChannelControls = (props: ChannelControlsProps) => {
100107
<EuiFlexItem>
101108
<EuiFieldSearch
102109
fullWidth={true}
103-
placeholder="Search"
110+
placeholder={i18n.translate('notification.notificationChannels.searchPlaceholder', {
111+
defaultMessage:
112+
"Search",
113+
})}
104114
onSearch={props.onSearchChange}
105115
/>
106116
</EuiFlexItem>
@@ -143,7 +153,10 @@ export const ChannelControls = (props: ChannelControlsProps) => {
143153
grow={false}
144154
onClick={() => setIsTypePopoverOpen(!isTypePopoverOpen)}
145155
>
146-
{isItemSelected(typeItems) ? <b>Type</b> : 'Type'}
156+
{isItemSelected(typeItems) ? <b>Type</b> : i18n.translate('tification.notificationChannels.notificationType', {
157+
defaultMessage:
158+
'Type',
159+
})}
147160
</EuiFilterButton>
148161
}
149162
isOpen={isTypePopoverOpen}

0 commit comments

Comments
 (0)