diff --git a/webapp/src/translationTools/TranslatedWarningBox.tsx b/webapp/src/translationTools/TranslatedWarningBox.tsx
new file mode 100644
index 0000000000..07cc0d950d
--- /dev/null
+++ b/webapp/src/translationTools/TranslatedWarningBox.tsx
@@ -0,0 +1,18 @@
+import { Alert, AlertTitle } from '@mui/material';
+import { useImportWarningTranslation } from 'tg.translationTools/useImportWarningTranslation';
+
+type Props = {
+ code: string;
+};
+
+export function TranslatedWarningBox({ code }: Props) {
+ const importWarningTranslation = useImportWarningTranslation();
+ const translation = importWarningTranslation(code);
+
+ return (
+
+ {translation.title}
+ {translation.message}
+
+ );
+}
diff --git a/webapp/src/translationTools/useErrorTranslation.ts b/webapp/src/translationTools/useErrorTranslation.ts
index 4f6de118ca..e27d4f9970 100644
--- a/webapp/src/translationTools/useErrorTranslation.ts
+++ b/webapp/src/translationTools/useErrorTranslation.ts
@@ -155,14 +155,6 @@ export function useErrorTranslation() {
return t('namespace_cannot_be_used_when_feature_is_disabled');
case 'namespaces_cannot_be_disabled_when_namespace_exists':
return t('namespaces_cannot_be_disabled_when_namespace_exists');
- case 'import_file_warning_header_namespace_cannot_be_used_when_feature_is_disabled':
- return t(
- 'import_file_warning_header_namespace_cannot_be_used_when_feature_is_disabled'
- );
- case 'import_file_warning_message_namespace_cannot_be_used_when_feature_is_disabled':
- return t(
- 'import_file_warning_message_namespace_cannot_be_used_when_feature_is_disabled'
- );
default:
return code;
}
diff --git a/webapp/src/translationTools/useImportWarningTranslation.ts b/webapp/src/translationTools/useImportWarningTranslation.ts
index ba47b37fd5..e72f771064 100644
--- a/webapp/src/translationTools/useImportWarningTranslation.ts
+++ b/webapp/src/translationTools/useImportWarningTranslation.ts
@@ -5,16 +5,20 @@ export function useImportWarningTranslation() {
return (code: string) => {
switch (code.toLocaleLowerCase()) {
- case 'import_file_warning_header_namespace_cannot_be_used_when_feature_is_disabled':
- return t(
- 'import_file_warning_header_namespace_cannot_be_used_when_feature_is_disabled'
- );
- case 'import_file_warning_message_namespace_cannot_be_used_when_feature_is_disabled':
- return t(
- 'import_file_warning_message_namespace_cannot_be_used_when_feature_is_disabled'
- );
+ case 'namespace_cannot_be_used_when_feature_is_disabled':
+ return {
+ title: t(
+ 'warning_header_namespace_cannot_be_used_when_feature_is_disabled'
+ ),
+ message: t(
+ 'warning_message_namespace_cannot_be_used_when_feature_is_disabled'
+ ),
+ };
default:
- return code;
+ return {
+ title: `warning_header_${code}`,
+ message: `warning_message_${code}`,
+ };
}
};
}
diff --git a/webapp/src/views/projects/import/ImportView.tsx b/webapp/src/views/projects/import/ImportView.tsx
index b9d9057aa2..28c5c4075a 100644
--- a/webapp/src/views/projects/import/ImportView.tsx
+++ b/webapp/src/views/projects/import/ImportView.tsx
@@ -1,5 +1,5 @@
import React, { FunctionComponent, useEffect, useState } from 'react';
-import { Alert, AlertTitle, Box, Button } from '@mui/material';
+import { Box, Button } from '@mui/material';
import { T, useTranslate } from '@tolgee/react';
import { LINKS, PARAMS } from 'tg.constants/links';
@@ -21,7 +21,7 @@ import { useImportDataHelper } from './hooks/useImportDataHelper';
import { BaseProjectView } from '../BaseProjectView';
import { ImportResultLoadingOverlay } from './component/ImportResultLoadingOverlay';
import { ImportSettingsPanel } from './component/ImportSettingsPanel';
-import { useImportWarningTranslation } from 'tg.translationTools/useImportWarningTranslation';
+import { TranslatedWarningBox } from 'tg.translationTools/TranslatedWarningBox';
export const ImportView: FunctionComponent = () => {
const dataHelper = useImportDataHelper();
@@ -37,7 +37,6 @@ export const ImportView: FunctionComponent = () => {
const { refetchUsage } = useGlobalActions();
const { t } = useTranslate();
- const importWarningTranslation = useImportWarningTranslation();
const onConflictResolutionDialogClose = () => {
dataHelper.refetchData();
@@ -127,16 +126,7 @@ export const ImportView: FunctionComponent = () => {
))}
{dataHelper.addFilesMutation.data?.warnings.map((item) => (
-
-
- {importWarningTranslation(
- 'import_file_warning_header_' + item.code
- )}
-
- {importWarningTranslation(
- 'import_file_warning_message_' + item.code
- )}
-
+
))}