Changed all user facing strings to use the i18n implementation.
This commit is contained in:
1 parent
d335cfb4ee
commit
93462d7ba6
3 files changed
+72
-7
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
import { useState, useMemo } from "react";
|
import { useState, useMemo } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
DialogContent,
|
DialogContent,
|
||||||
@@ -18,12 +19,16 @@ const NOTIFICATION_TYPES = [
|
|||||||
{
|
{
|
||||||
id: 'slack',
|
id: 'slack',
|
||||||
label: 'Slack',
|
label: 'Slack',
|
||||||
|
labelKey: 'notifications.slack.label',
|
||||||
description: 'To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.',
|
description: 'To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.',
|
||||||
|
descriptionKey: 'notifications.slack.description',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
id: 'webhook',
|
id: 'webhook',
|
||||||
label: 'Webhook URL',
|
label: 'Webhook URL',
|
||||||
|
labelKey: 'notifications.slack.webhookLabel',
|
||||||
placeholder: 'https://hooks.slack.com/services/...',
|
placeholder: 'https://hooks.slack.com/services/...',
|
||||||
|
placeholderKey: 'notifications.slack.webhookPlaceholder',
|
||||||
type: 'text'
|
type: 'text'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -31,12 +36,16 @@ const NOTIFICATION_TYPES = [
|
|||||||
{
|
{
|
||||||
id: 'discord',
|
id: 'discord',
|
||||||
label: 'Discord',
|
label: 'Discord',
|
||||||
|
labelKey: 'notifications.discord.label',
|
||||||
description: 'To send data to a Discord channel from Checkmate via Discord notifications using webhooks, you can use Discord\'s incoming Webhooks feature.',
|
description: 'To send data to a Discord channel from Checkmate via Discord notifications using webhooks, you can use Discord\'s incoming Webhooks feature.',
|
||||||
|
descriptionKey: 'notifications.discord.description',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
id: 'webhook',
|
id: 'webhook',
|
||||||
label: 'Discord Webhook URL',
|
label: 'Discord Webhook URL',
|
||||||
|
labelKey: 'notifications.discord.webhookLabel',
|
||||||
placeholder: 'https://discord.com/api/webhooks/...',
|
placeholder: 'https://discord.com/api/webhooks/...',
|
||||||
|
placeholderKey: 'notifications.discord.webhookPlaceholder',
|
||||||
type: 'text'
|
type: 'text'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -44,18 +53,24 @@ const NOTIFICATION_TYPES = [
|
|||||||
{
|
{
|
||||||
id: 'telegram',
|
id: 'telegram',
|
||||||
label: 'Telegram',
|
label: 'Telegram',
|
||||||
|
labelKey: 'notifications.telegram.label',
|
||||||
description: 'To enable Telegram notifications, create a Telegram bot using BotFather, an official bot for creating and managing Telegram bots. Then, get the API token and chat ID and write them down here.',
|
description: 'To enable Telegram notifications, create a Telegram bot using BotFather, an official bot for creating and managing Telegram bots. Then, get the API token and chat ID and write them down here.',
|
||||||
|
descriptionKey: 'notifications.telegram.description',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
id: 'token',
|
id: 'token',
|
||||||
label: 'Your bot token',
|
label: 'Your bot token',
|
||||||
|
labelKey: 'notifications.telegram.tokenLabel',
|
||||||
placeholder: '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',
|
placeholder: '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',
|
||||||
|
placeholderKey: 'notifications.telegram.tokenPlaceholder',
|
||||||
type: 'text'
|
type: 'text'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'chatId',
|
id: 'chatId',
|
||||||
label: 'Your Chat ID',
|
label: 'Your Chat ID',
|
||||||
|
labelKey: 'notifications.telegram.chatIdLabel',
|
||||||
placeholder: '-1001234567890',
|
placeholder: '-1001234567890',
|
||||||
|
placeholderKey: 'notifications.telegram.chatIdPlaceholder',
|
||||||
type: 'text'
|
type: 'text'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -63,12 +78,16 @@ const NOTIFICATION_TYPES = [
|
|||||||
{
|
{
|
||||||
id: 'webhook',
|
id: 'webhook',
|
||||||
label: 'Webhooks',
|
label: 'Webhooks',
|
||||||
|
labelKey: 'notifications.webhook.label',
|
||||||
description: 'You can set up a custom webhook to receive notifications when incidents occur.',
|
description: 'You can set up a custom webhook to receive notifications when incidents occur.',
|
||||||
|
descriptionKey: 'notifications.webhook.description',
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
id: 'url',
|
id: 'url',
|
||||||
label: 'Webhook URL',
|
label: 'Webhook URL',
|
||||||
|
labelKey: 'notifications.webhook.urlLabel',
|
||||||
placeholder: 'https://your-server.com/webhook',
|
placeholder: 'https://your-server.com/webhook',
|
||||||
|
placeholderKey: 'notifications.webhook.urlPlaceholder',
|
||||||
type: 'text'
|
type: 'text'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -83,6 +102,7 @@ const NotificationIntegrationModal = ({
|
|||||||
// Optional prop to configure available notification types
|
// Optional prop to configure available notification types
|
||||||
notificationTypes = NOTIFICATION_TYPES
|
notificationTypes = NOTIFICATION_TYPES
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [tabValue, setTabValue] = useState(0);
|
const [tabValue, setTabValue] = useState(0);
|
||||||
|
|
||||||
@@ -200,7 +220,7 @@ const NotificationIntegrationModal = ({
|
|||||||
color: theme.palette.primary.contrastTextSecondary,
|
color: theme.palette.primary.contrastTextSecondary,
|
||||||
pl: theme.spacing(4)
|
pl: theme.spacing(4)
|
||||||
}}>
|
}}>
|
||||||
Add or edit notifications
|
{t('notifications.addOrEditNotifications', 'Add or edit notifications')}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Tabs
|
<Tabs
|
||||||
@@ -213,7 +233,7 @@ const NotificationIntegrationModal = ({
|
|||||||
{notificationTypes.map((type) => (
|
{notificationTypes.map((type) => (
|
||||||
<Tab
|
<Tab
|
||||||
key={type.id}
|
key={type.id}
|
||||||
label={type.label}
|
label={t(type.labelKey, type.label)}
|
||||||
orientation="vertical"
|
orientation="vertical"
|
||||||
disableRipple
|
disableRipple
|
||||||
/>
|
/>
|
||||||
@@ -230,7 +250,16 @@ const NotificationIntegrationModal = ({
|
|||||||
{notificationTypes.map((type, index) => (
|
{notificationTypes.map((type, index) => (
|
||||||
<TabPanel key={type.id} value={tabValue} index={index}>
|
<TabPanel key={type.id} value={tabValue} index={index}>
|
||||||
<TabComponent
|
<TabComponent
|
||||||
type={type}
|
type={{
|
||||||
|
...type,
|
||||||
|
label: t(type.labelKey, type.label),
|
||||||
|
description: t(type.descriptionKey, type.description),
|
||||||
|
fields: type.fields.map(field => ({
|
||||||
|
...field,
|
||||||
|
label: t(field.labelKey, field.label),
|
||||||
|
placeholder: t(field.placeholderKey, field.placeholder)
|
||||||
|
}))
|
||||||
|
}}
|
||||||
integrations={integrations}
|
integrations={integrations}
|
||||||
handleIntegrationChange={handleIntegrationChange}
|
handleIntegrationChange={handleIntegrationChange}
|
||||||
handleInputChange={handleInputChange}
|
handleInputChange={handleInputChange}
|
||||||
@@ -258,7 +287,7 @@ const NotificationIntegrationModal = ({
|
|||||||
px: theme.spacing(8)
|
px: theme.spacing(8)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Save
|
{t('common.save', 'Save')}
|
||||||
</Button>
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import {
|
|||||||
Box,
|
Box,
|
||||||
Button
|
Button
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import TextInput from "../../../src/Components/Inputs/TextInput";
|
import TextInput from "../../../src/Components/Inputs/TextInput";
|
||||||
import Checkbox from "../../../src/Components/Inputs/Checkbox";
|
import Checkbox from "../../../src/Components/Inputs/Checkbox";
|
||||||
|
|
||||||
const TabComponent = ({
|
const TabComponent = ({
|
||||||
type,
|
type,
|
||||||
integrations,
|
integrations,
|
||||||
@@ -15,6 +17,7 @@ const TabComponent = ({
|
|||||||
handleTestNotification
|
handleTestNotification
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
// Helper to get the field state key (e.g., slackWebhook, telegramToken)
|
// Helper to get the field state key (e.g., slackWebhook, telegramToken)
|
||||||
const getFieldKey = (typeId, fieldId) => {
|
const getFieldKey = (typeId, fieldId) => {
|
||||||
@@ -49,7 +52,7 @@ const TabComponent = ({
|
|||||||
<Box sx={{ pl: theme.spacing(1.5) }}>
|
<Box sx={{ pl: theme.spacing(1.5) }}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
id={`enable-${type.id}`}
|
id={`enable-${type.id}`}
|
||||||
label={`Enable ${type.label} notifications`}
|
label={t('notifications.enableNotifications', { platform: type.label })}
|
||||||
isChecked={integrations[type.id]}
|
isChecked={integrations[type.id]}
|
||||||
onChange={(e) => handleIntegrationChange(type.id, e.target.checked)}
|
onChange={(e) => handleIntegrationChange(type.id, e.target.checked)}
|
||||||
/>
|
/>
|
||||||
@@ -87,7 +90,7 @@ const TabComponent = ({
|
|||||||
onClick={() => handleTestNotification(type.id)}
|
onClick={() => handleTestNotification(type.id)}
|
||||||
disabled={!integrations[type.id] || !areAllFieldsFilled()}
|
disabled={!integrations[type.id] || !areAllFieldsFilled()}
|
||||||
>
|
>
|
||||||
Test notification
|
{t('notifications.testNotification')}
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
|
|||||||
+34
-1
@@ -107,5 +107,38 @@
|
|||||||
"settingsDemoMonitorsAdded": "Successfully added demo monitors",
|
"settingsDemoMonitorsAdded": "Successfully added demo monitors",
|
||||||
"settingsFailedToAddDemoMonitors": "Failed to add demo monitors",
|
"settingsFailedToAddDemoMonitors": "Failed to add demo monitors",
|
||||||
"settingsMonitorsDeleted": "Successfully deleted all monitors",
|
"settingsMonitorsDeleted": "Successfully deleted all monitors",
|
||||||
"settingsFailedToDeleteMonitors": "Failed to delete all monitors"
|
"settingsFailedToDeleteMonitors": "Failed to delete all monitors",
|
||||||
|
|
||||||
|
"notifications": {
|
||||||
|
"enableNotifications": "Enable {{platform}} notifications",
|
||||||
|
"testNotification": "Test notification",
|
||||||
|
"addOrEditNotifications": "Add or edit notifications",
|
||||||
|
"slack": {
|
||||||
|
"label": "Slack",
|
||||||
|
"description": "To enable Slack notifications, create a Slack app and enable incoming webhooks. After that, simply provide the webhook URL here.",
|
||||||
|
"webhookLabel": "Webhook URL",
|
||||||
|
"webhookPlaceholder": "https://hooks.slack.com/services/..."
|
||||||
|
},
|
||||||
|
"discord": {
|
||||||
|
"label": "Discord",
|
||||||
|
"description": "To send data to a Discord channel from Checkmate via Discord notifications using webhooks, you can use Discord's incoming Webhooks feature.",
|
||||||
|
"webhookLabel": "Discord Webhook URL",
|
||||||
|
"webhookPlaceholder": "https://discord.com/api/webhooks/..."
|
||||||
|
},
|
||||||
|
"telegram": {
|
||||||
|
"label": "Telegram",
|
||||||
|
"description": "To enable Telegram notifications, create a Telegram bot using BotFather, an official bot for creating and managing Telegram bots. Then, get the API token and chat ID and write them down here.",
|
||||||
|
"tokenLabel": "Your bot token",
|
||||||
|
"tokenPlaceholder": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
|
||||||
|
"chatIdLabel": "Your Chat ID",
|
||||||
|
"chatIdPlaceholder": "-1001234567890"
|
||||||
|
},
|
||||||
|
"webhook": {
|
||||||
|
"label": "Webhooks",
|
||||||
|
"description": "You can set up a custom webhook to receive notifications when incidents occur.",
|
||||||
|
"urlLabel": "Webhook URL",
|
||||||
|
"urlPlaceholder": "https://your-server.com/webhook"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user