Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added export without auto translation option #2704

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/containers/Flow/FlowTranslation.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
z-index: 100000;
font-size: 20px;
}

.FormHelper {
padding-left: 16px;
margin-bottom: 10px;
}

.Radio {
padding: 0px 8px;
}
47 changes: 42 additions & 5 deletions src/containers/Flow/FlowTranslation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Radio,
Backdrop,
CircularProgress,
FormHelperText,
} from '@mui/material';
import { useTranslation } from 'react-i18next';
import styles from './FlowTranslation.module.css';
Expand Down Expand Up @@ -82,14 +83,20 @@
};

const handleExport = async () => {
exportFlowTranslations({ variables: { id: flowId } });
exportFlowTranslations({ variables: { id: flowId, addTranslation: false } });

Check warning on line 86 in src/containers/Flow/FlowTranslation.tsx

View check run for this annotation

Codecov / codecov/patch

src/containers/Flow/FlowTranslation.tsx#L86

Added line #L86 was not covered by tests
};

const handleAutoExport = () => {
exportFlowTranslations({ variables: { id: flowId, addTranslation: true } });

Check warning on line 90 in src/containers/Flow/FlowTranslation.tsx

View check run for this annotation

Codecov / codecov/patch

src/containers/Flow/FlowTranslation.tsx#L90

Added line #L90 was not covered by tests
};

const handleOk = () => {
if (action === 'auto') {
handleAuto();
} else if (action === 'export') {
handleExport();
} else if (action === 'export-auto') {
handleAutoExport();

Check warning on line 99 in src/containers/Flow/FlowTranslation.tsx

View check run for this annotation

Codecov / codecov/patch

src/containers/Flow/FlowTranslation.tsx#L99

Added line #L99 was not covered by tests
}
};

Expand Down Expand Up @@ -119,6 +126,29 @@
return <BackdropLoader text="Please wait while the flow is getting translated..." />;
}

const translationOptions = [
{
value: 'auto',
label: t('Automatic translation'),
description: t('Generate translations for all available languages automatically.'),
},
{
value: 'export-auto',
label: t('Export with auto translate'),
description: t('Translate the content and export it as a CSV file.'),
},
{
value: 'export',
label: t('Export translations'),
description: t('Export the content without any automatic translations.'),
},
{
value: 'import',
label: t('Import translations'),
description: t('Import translations from a CSV file into the application.'),
},
];

const dialogContent = (
<div>
<FormControl>
Expand All @@ -129,9 +159,16 @@
onChange={handleChange}
data-testid="translation-options"
>
<FormControlLabel value="auto" control={<Radio />} label={t('Automatic translation')} />
<FormControlLabel value="export" control={<Radio />} label={t('Export translations')} />
<FormControlLabel value="import" control={<Radio />} label={t('Import translations')} />
{translationOptions.map((option) => (
<div key={option.value}>
<FormControlLabel
value={option.value}
control={<Radio className={styles.Radio} />}
label={option.label}
/>
<FormHelperText className={styles.FormHelper}>{option.description}</FormHelperText>
</div>
))}
</RadioGroup>
{action === 'import' ? importButton : ''}
</FormControl>
Expand All @@ -140,7 +177,7 @@

return (
<DialogBox
title="Translate Flow"
title="Translate Options"
alignButtons="center"
buttonOk="Submit"
buttonCancel="Cancel"
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/queries/Flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export const RELEASE_FLOW = gql`
`;

export const EXPORT_FLOW_LOCALIZATIONS = gql`
query exportFlowLocalization($id: ID!) {
exportFlowLocalization(id: $id) {
query exportFlowLocalization($id: ID!, $addTranslation: Boolean) {
exportFlowLocalization(id: $id, addTranslation: $addTranslation) {
exportData
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/i18n/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,5 +442,10 @@
"Response JSON": "Response JSON",
"Webhook Logs": "Webhook Logs",
"Translate": "Translate",
"An error occured while translating flows.": "An error occured while translating flows."
"An error occured while translating flows.": "An error occured while translating flows.",
"Export with auto translate": "Export with auto translate",
"Generate translations for all available languages automatically.": "Generate translations for all available languages automatically.",
"Translate the content and export it as a CSV file.": "Translate the content and export it as a CSV file.",
"Export the content without any automatic translations.": "Export the content without any automatic translations.",
"Import translations from a CSV file into the application.": "Import translations from a CSV file into the application."
}
Loading