Skip to content

Commit

Permalink
turned strings in checkState into translations
Browse files Browse the repository at this point in the history
  • Loading branch information
danielshid committed Dec 6, 2024
1 parent be0272d commit 42d8616
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,46 +87,46 @@ export default function EditConversionModalComponent(props: EditConversionModalC
let msg = '';
let cancel = false;
if (source.typeOfUnit === UnitType.meter) {
const count = getConversionCount(source, conversionDetails);
if (count === 1) {
msg += `Deleting this meter conversion will orphan ${unitDataById[state.destinationId].name}.\n`;
const srcCount = getConversionCount(source, conversionDetails);
if (srcCount === 1) {
msg += `${translate('conversion.delete.meter.orphan')} "${unitDataById[state.destinationId].name}".\n`;
} else {
msg += 'Deleting this meter conversion will make the following meter(s) ungraphable:\n';
msg += `${translate('conversion.delete.meter.ungraphable')}\n`;
for (const meterId of Object.values(meterDataById)) {
if (meterId.unitId == source.id) {
msg += `${meterId.name}\n`;
if (meterId.unitId === source.id) {
msg += `"${meterId.name}"\n`;
cancel = true;
}
}
}
} else if (source.typeOfUnit === UnitType.suffix) {
const count = getConversionCount(source, conversionDetails);
if (count === 1) {
msg += `Deleting this suffix conversion will disable use of ${source.name}.\n`;
const srcCount = getConversionCount(source, conversionDetails);
if (srcCount === 1) {
msg += `${translate('conversion.delete.suffix.disable')} "${source.name}".\n`;
}
} else if (source.typeOfUnit === UnitType.unit && dest.typeOfUnit === UnitType.unit) {
const destCount = getConversionCount(dest, conversionDetails);
if (destCount === 1) {
msg += `Deleting this unit conversion will orphan ${unitDataById[state.destinationId].name}.\n`;
msg += `${translate('conversion.delete.unit.orphan')} "${unitDataById[state.destinationId].name}".\n`;
}
if (state.bidirectional) {
const sourceCount = getConversionCount(source, conversionDetails);
if (sourceCount === 1) {
msg += `Deleting this unit conversion will orphan ${unitDataById[state.destinationId].name}.\n`;
const srcCount = getConversionCount(source, conversionDetails);
if (srcCount === 1) {
msg += `${translate('conversion.delete.unit.orphan')} "${unitDataById[state.destinationId].name}".\n`;
}
}
if (msg === '') {
msg += 'Deleting this unit conversion between two units of type unit will have consequences.\n';
msg += `${translate('conversion.delete.unit')}\n`;
}
}

if (msg === '') {
handleDeleteConfirmationModalOpen();
} else if (cancel) {
setDeleteConfirmationMessage(msg + 'This conversion cannot be deleted.\n');
setDeleteConfirmationMessage(msg + `${translate('conversion.delete.restricted')}\n`);
handleCancelModalOpen();
} else {
setDeleteConfirmationMessage(msg + deleteConfirmationMessage);
setDeleteConfirmationMessage(msg + translate('conversion.delete.conversion') + ' [' + props.conversionIdentifier + '] ?');
handleDeleteConfirmationModalOpen();
}
};
Expand Down
18 changes: 18 additions & 0 deletions src/client/app/translations/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ const LocaleTranslationData = {
"conversion.create.source.destination.not": "Source or destination not set",
"conversion.create.source.destination.same": "The source and destination cannot be the same for a conversion",
"conversion.delete.conversion": "Delete Conversion",
"conversion.delete.meter.orphan": "Deleting this meter conversion will orphan meter",
"conversion.delete.meter.ungraphable": "Deleting this meter conversion will make the following meter(s) ungraphable:",
"conversion.delete.restricted": "This conversion cannot be deleted until the significant consequences of doing this are addressed.",
"conversion.delete.suffix.disable": "Deleting this suffix conversion will disable use of suffix",
"conversion.delete.unit" : "Deleting this conversion between two units of type unit may reduce the possible graphing units for some meter(s) but cannot be known until after the deletion happens.",
"conversion.delete.unit.orphan": "Deleting this unit conversion will orphan unit",
"conversion.destination": "Destination:",
"conversion.dropdown.displayable.option.admin": "Admin",
"conversion.edit.conversion": "Edit Conversion",
Expand Down Expand Up @@ -585,6 +591,12 @@ const LocaleTranslationData = {
"conversion.create.source.destination.not": "Source or destination not set\u{26A1}",
"conversion.create.source.destination.same": "The source and destination cannot be the same for a conversion\u{26A1}",
"conversion.delete.conversion": "Delete Conversion\u{26A1}",
"conversion.delete.meter.orphan": "Deleting this meter conversion will orphan meter\u{26A1}",
"conversion.delete.meter.ungraphable": "Deleting this meter conversion will make the following meter(s) ungraphable:\u{26A1}",
"conversion.delete.restricted": "This conversion cannot be deleted until the significant consequences of doing this are addressed.\u{26A1}",
"conversion.delete.suffix.disable": "Deleting this suffix conversion will disable use of suffix\u{26A1}",
"conversion.delete.unit" : "Deleting this conversion between two units of type unit may reduce the possible graphing units for some meter(s) but cannot be known until after the deletion happens.\u{26A1}",
"conversion.delete.unit.orphan": "Deleting this unit conversion will orphan unit\u{26A1}",
"conversion.destination": "Destination:\u{26A1}",
"conversion.dropdown.displayable.option.admin": "admin\u{26A1}",
"conversion.edit.conversion": "Edit Conversion\u{26A1}",
Expand Down Expand Up @@ -1107,6 +1119,12 @@ const LocaleTranslationData = {
"conversion.create.source.destination.not": "Fuente o destinación no establecida.",
"conversion.create.source.destination.same": "La fuente y destinación no pueden ser la misma para una conversión",
"conversion.delete.conversion": "Eliminar conversión",
"conversion.delete.meter.orphan": "Deleting this meter conversion will orphan meter\u{26A1}",
"conversion.delete.meter.ungraphable": "Deleting this meter conversion will make the following meter(s) ungraphable:\u{26A1}",
"conversion.delete.restricted": "This conversion cannot be deleted until the significant consequences of doing this are addressed.\u{26A1}",
"conversion.delete.suffix.disable": "Deleting this suffix conversion will disable use of suffix\u{26A1}",
"conversion.delete.unit" : "Deleting this conversion between two units of type unit may reduce the possible graphing units for some meter(s) but cannot be known until after the deletion happens.\u{26A1}",
"conversion.delete.unit.orphan": "Deleting this unit conversion will orphan unit\u{26A1}",
"conversion.destination": "Destinación",
"conversion.dropdown.displayable.option.admin": "Administrador",
"conversion.edit.conversion": "Editar conversión",
Expand Down

0 comments on commit 42d8616

Please sign in to comment.