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

Localize error messages #572

Merged
merged 3 commits into from
Sep 23, 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
108 changes: 108 additions & 0 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,113 @@
"rename": "Přejmenovat",
"save": "Uložit",
"discard": "Zahodit"
},

"error": {
"default": "Došlo k chybě",
"faultEvent": {
"findAll": "Nepodařilo se najít události závad. {{error}}",
"update": "Nepodařilo se aktualizovat událost závady. {{error}}",
"remove": "Nepodařilo se odstranit událost závady. {{error}}",
"create": "Nepodařilo se vytvořit událost. {{error}}",
"updateRectangle": "Nepodařilo se aktualizovat obdélník. {{error}}",
"getFailureMode": "Nepodařilo se načíst režim selhání události. {{error}}",
"deleteFailureMode": "Nepodařilo se smazat režim selhání události. {{error}}",
"updateChildrenSequence": "Nepodařilo se aktualizovat pořadí dětí. {{error}}",
"getRootReusable": "Nepodařilo se najít znovu použitelné události závady. {{error}}",
"getAllReusable": "Nepodařilo se najít všechny znovu použitelné události závady. {{error}}",
"probabilityNotSet": "Výpočet pravděpodobnosti FTA - Událost \"{{event}}\"<{{uri}}>, nemá určenou pravděpodobnost a je použita pro výpočet pravděpodobnosti nadřazené události.",
"childProbabilityNotSet": "Výpočet pravděpodobnosti FTA - Nelze vypočítat pravděpodobnost události \"{{event}}\"<{{uri}}>, některé podřízené události nemají určenou pravděpodobnost."
},
"faultTree": {
"rootEvent": {
"deleteViolation": "Kořenová událost stromu nemůže být smazána!"
},
"intermediateEventAsLeaf": "Mezilehlá událost nemůže být na konci cesty!",
"findAll": "Nepodařilo se načíst stromy závad. {{error}}",
"findAllWithFilters": "Nepodařilo se načíst stromy závad s filtry. {{error}}",
"find": "Nepodařilo se najít strom závad. {{error}}",
"create": "Nepodařilo se vytvořit strom závad. {{error}}",
"update": "Nepodařilo se aktualizovat strom závad. {{error}}",
"remove": "Nepodařilo se odstranit strom závad. {{error}}",
"getTreePaths": "Nepodařilo se načíst cesty stromu. {{error}}",
"getTreePathsAggregate": "Nepodařilo se načíst všechny cesty stromu. {{error}}",
"calculateCutSets": "Nepodařilo se vypočítat řezové množiny stromu závad. {{error}}",
"leafEvents": {
"noProbability": "Následující základní události nemají určenou pravděpodobnost: [{{leafEvents}}]"
}
},
"function": {
"findAll": "Nepodařilo se načíst funkce. {{error}}",
"addRequiredFunction": "Nepodařilo se přidat požadovanou funkci. {{error}}",
"update": "Nepodařilo se aktualizovat funkci. {{error}}",
"getImpairedBehaviour": "Nepodařilo se získat narušené chování. {{error}}",
"create": "Nepodařilo se vytvořit funkci. {{error}}",
"add": "Nepodařilo se přidat existující funkci. {{error}}",
"remove": "Nepodařilo se odstranit funkci. {{error}}"
},
"mitigation": {
"update": "Nepodařilo se aktualizovat zmírnění. {{error}}"
},
"system": {
"findAll": "Nepodařilo se načíst systémy. {{error}}",
"find": "Nepodařilo se najít systém. {{error}}",
"create": "Nepodařilo se vytvořit systém. {{error}}",
"update": "Nepodařilo se aktualizovat systém. {{error}}",
"remove": "Nepodařilo se odstranit systém. {{error}}",
"updateFilter": "Nepodařilo se aktualizovat filtr provozních dat. {{error}}",
"removeWithFaultTrees": "Nelze odstranit systém \"{{systemName}}\" ({{instanceUri}}), systém má {{faultTreeCount}} stromů závad.",
"nameExists": "Systém se jménem \"{{systemName}}\" již existuje"
},
"component": {
"mergeComponent": "Nepodařilo se sloučit komponenty. {{error}}",
"findAll": "Nepodařilo se načíst komponenty. {{error}}",
"find": "Nepodařilo se načíst komponentu. {{error}}",
"create": "Nepodařilo se vytvořit komponentu. {{error}}",
"update": "Nepodařilo se aktualizovat komponentu. {{error}}",
"linkComponent": "Nepodařilo se propojit komponenty. {{error}}",
"unlinkComponent": "Nepodařilo se odpojit komponenty. {{error}}",
"remove": "Nepodařilo se odstranit komponentu. {{error}}",
"add": "Nepodařilo se přidat komponentu. {{error}}"
},
"failureMode": {
"findAll": "Nepodařilo se načíst režimy selhání. {{error}}",
"find": "Nepodařilo se načíst režim selhání. {{error}}",
"create": "Nepodařilo se vytvořit režim selhání. {{error}}",
"update": "Nepodařilo se aktualizovat režim selhání. {{error}}",
"add": "Nepodařilo se přidat režim selhání. {{error}}",
"remove": "Nepodařilo se odstranit režim selhání. {{error}}"
},
"failureModesRow": {
"update": "Nepodařilo se aktualizovat řádek režimů selhání rpn. {{error}}"
},
"failureModesTable": {
"findAll": "Nepodařilo se načíst tabulky režimů selhání. {{error}}",
"update": "Nepodařilo se aktualizovat tabulky režimů selhání. {{error}}",
"create": "Nepodařilo se vytvořit tabulku režimů selhání. {{error}}",
"remove": "Nepodařilo se odstranit tabulky režimů selhání. {{error}}",
"computeTableData": "Nepodařilo se načíst data tabulky režimů selhání. {{error}}",
"export": "Nepodařilo se exportovat tabulku režimů selhání. {{error}}",
"createAggregate": "Nepodařilo se vytvořit agregátní tabulku režimů selhání. {{error}}"
},
"document": {
"import": "Nepodařilo se importovat dokument. {{error}}",
"findAll": "Nepodařilo se načíst dokumenty. {{error}}"
},
"user": {
"update": {
"uriMismatch": "URI pro aktualizaci uživatele se neshoduje s aktuálním uživatelem!",
"incorrectOldPassword": "Stará heslo je nesprávné!"
},
"impersonation": {
"adminImpersonation": "Nelze se vydávat za administrátora."
},
"register": "Registrace se nezdařila. {{error}}",
"login": "Přihlášení se nezdařilo. {{error}}",
"password": "Změna hesla se nezdařila. {{error}}",
"passwordMismatch": "Zadané heslo pro uživatelské jméno \"{{username}}\" neodpovídá.",
"usernameNotAvailable": "Uživatelské jméno \"{{username}}\" již bylo použito."
},
"entityNotFound": "\"{{resourceName}}\" identifikovaný pomocí \"{{identifier}}\" nebyl nalezen."
}
}
107 changes: 107 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,112 @@
"rename": "Rename",
"save": "Save",
"discard": "Discard"
},
"error": {
"default": "An error occurred",
"faultEvent": {
"findAll": "Failed to find fault events. {{error}}",
"update": "Failed to update fault event. {{error}}",
"remove": "Failed to remove fault event. {{error}}",
"create": "Failed to create event. {{error}}",
"updateRectangle": "Failed to update rectangle. {{error}}",
"getFailureMode": "Failed to load event failure mode. {{error}}",
"deleteFailureMode": "Failed to delete event failure mode. {{error}}",
"updateChildrenSequence": "Failed to update children sequence. {{error}}",
"getRootReusable": "Failed to find reusable fault events. {{error}}",
"getAllReusable": "Failed to find all reusable fault events. {{error}}",
"probabilityNotSet": "FTA probability calculation - Event, \"{{event}}\"{{uri}}, has no specified probability and is used to calculate probability of parent event.\",",
"childProbabilityNotSet": "FTA probability calculation - Cannot calculate probability of \"{{event}}\"{{uri}}, some child events have no specified probability."
},
"faultTree": {
"rootEvent": {
"deleteViolation": "Root event of tree mustn't be deleted!"
},
"intermediateEventAsLeaf": "Intermediate event must not be the end of the path!",
"findAll": "Failed to load fault trees. {{error}}",
"findAllWithFilters": "Failed to load fault trees with filters. {{error}}",
"find": "Failed to find fault tree. {{error}}",
"create": "Failed to create fault tree. {{error}}",
"update": "Failed to update fault tree. {{error}}",
"remove": "Failed to remove fault tree. {{error}}",
"getTreePaths": "Failed to load tree paths. {{error}}",
"getTreePathsAggregate": "Failed to load all tree paths. {{error}}",
"calculateCutSets": "Failed to calculate cutsets of fault tree. {{error}}",
"leafEvents": {
"noProbability": "The following leaf events do not have specified probability: [{{leafEvents}}]"
}
},
"function": {
"findAll": "Failed to load functions. {{error}}",
"addRequiredFunction": "Failed to add required Function. {{error}}",
"update": "Failed to update function. {{error}}",
"getImpairedBehaviour": "Failed to get impaired behaviors. {{error}}",
"create": "Failed to create function. {{error}}",
"add": "Failed to add existing function. {{error}}",
"remove": "Failed to remove function. {{error}}"
},
"mitigation": {
"update": "Failed to update mitigation. {{error}}"
},
"system": {
"findAll": "Failed to load systems. {{error}}",
"find": "Failed to find system. {{error}}",
"create": "Failed to create system. {{error}}",
"update": "Failed to update system. {{error}}",
"remove": "Failed to remove system. {{error}}",
"updateFilter": "Failed to operational data filter. {{error}}",
"removeWithFaultTrees": "Cannot remove system \"{{systemName}}\" ({{instanceUri}}), the system has {{faultTreeCount}} fault trees.",
"nameExists": "System with name \"{{systemName}}\" already exists"
},
"component": {
"mergeComponent": "Failed to merge components. {{error}}",
"findAll": "Failed to load components. {{error}}",
"find": "Failed to load component. {{error}}",
"create": "Failed to create component. {{error}}",
"update": "Failed to update component. {{error}}",
"linkComponent": "Failed to link components. {{error}}",
"unlinkComponent": "Failed to unlink components. {{error}}",
"remove": "Failed to remove component. {{error}}",
"add": "Failed to add component. {{error}}"
},
"failureMode": {
"findAll": "Failed to load failure modes. {{error}}",
"find": "Failed to load failure mode. {{error}}",
"create": "Failed to create failure mode. {{error}}",
"update": "Failed to update failure mode. {{error}}",
"add": "Failed to add failure mode. {{error}}",
"remove": "Failed to remove failure mode. {{error}}"
},
"failureModesRow": {
"update": "Failed to update failure modes row rpn. {{error}}"
},
"failureModesTable": {
"findAll": "Failed to load failure modes tables. {{error}}",
"update": "Failed to update failure modes tables. {{error}}",
"create": "Failed to create failure modes table. {{error}}",
"remove": "Failed to remove failure modes tables. {{error}}",
"computeTableData": "Failed to load failure modes table data. {{error}}",
"export": "Failed to export table data. {{error}}",
"createAggregate": "Failed to create failure modes aggregate table. {{error}}"
},
"document": {
"import": "Failed to import document. {{error}}",
"findAll": "Failed to load documents. {{error}}"
},
"user": {
"update": {
"uriMismatch": "User update uri does not match current user!",
"incorrectOldPassword": "Old password incorrect!"
},
"impersonation": {
"adminImpersonation": "Cannot impersonate admin."
},
"register": "Registration failed. {{error}}",
"login": "Login failed. {{error}}",
"passwordChange": "Password change failed. {{error}}",
"passwordMismatch": "Provided password for username \"{{username}}\" doesn't match.",
"usernameNotAvailable": "Username \"{{username}}\" has already been used."
},
"entityNotFound": "\"{{resourceName}}\" identified by \"{{identifier}}\" + not found."
}
}
44 changes: 15 additions & 29 deletions src/services/componentService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export async function mergeComponents(iri: string, iri2: string): Promise<void>
return new Promise<void>((resolve) => resolve());
} catch (e) {
console.log("Component Service - Failed to call /mergeComponents");
const defaultMessage = "Failed to merge components";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.mergeComponent")));
}
}

Expand All @@ -41,8 +40,7 @@ export const findAll = async (): Promise<Component[]> => {
return JsonLdUtils.compactAndResolveReferencesAsArray<Component>(response.data, CONTEXT);
} catch (e) {
console.log("Component Service - Failed to call /findAll");
const defaultMessage = "Failed to load components";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.findAll")));
}
};

Expand All @@ -57,8 +55,7 @@ export const create = async (component: CreateComponent): Promise<Component> =>
return JsonLdUtils.compactAndResolveReferences<Component>(response.data, CONTEXT);
} catch (e) {
console.log("Component Service - Failed to call /create");
const defaultMessage = "Failed to create component";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.create")));
}
};

Expand All @@ -72,7 +69,7 @@ export const update = async (componentUpdate: UpdateComponent): Promise<Componen
} catch (e) {
console.log("Component Service - Failed to call /update");
const defaultMessage = "Failed to update component";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.update")));
}
};

Expand All @@ -86,8 +83,7 @@ export const functions = async (componentUri: string): Promise<Function[]> => {
return JsonLdUtils.compactAndResolveReferencesAsArray<Function>(response.data, FUNCTION_CONTEXT);
} catch (e) {
console.log("Component Service - Failed to call /functions");
const defaultMessage = "Failed to load functions";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.functions.findAll")));
}
};

Expand All @@ -101,8 +97,7 @@ export const failureModes = async (componentUri: string): Promise<FailureMode[]>
return JsonLdUtils.compactAndResolveReferencesAsArray<FailureMode>(response.data, FAILURE_MODE_CONTEXT);
} catch (e) {
console.log("Component Service - Failed to call /failureModes");
const defaultMessage = "Failed to load failure modes";
return new Promise((_resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((_resolve, reject) => reject(handleServerError(e, "error.failureMode.findAll")));
}
};

Expand All @@ -121,8 +116,7 @@ export const addFunction = async (componentUri: string, f: Function): Promise<Fu
return JsonLdUtils.compactAndResolveReferences<Function>(response.data, CONTEXT);
} catch (e) {
console.log("Component Service - Failed to call create function");
const defaultMessage = "Failed to create function";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.function.create")));
}
};

Expand All @@ -143,8 +137,7 @@ export const addFunctionByURI = async (componentUri: string, functionUri: string
} catch (e) {
console.log(e);
console.log("Component Service - Failed to call add function by URI");
const defaultMessage = "Failed to add existing function";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.function.add")));
}
};

Expand All @@ -159,8 +152,7 @@ export const removeFunction = async (componentIri: string, functionIri: string)
return new Promise<void>((resolve) => resolve());
} catch (e) {
console.log("Component Service - Failed to call /removeFunction");
const defaultMessage = "Failed to remove function";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.function.remove")));
}
};

Expand All @@ -176,8 +168,7 @@ export const linkComponent = async (componentUri: string, linkUri: string): Prom
return JsonLdUtils.compactAndResolveReferences<Component>(response.data, CONTEXT);
} catch (e) {
console.log("Component Service - Failed to call /linkComponent");
const defaultMessage = "Failed to link components";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.linkComponent")));
}
};

Expand All @@ -192,8 +183,7 @@ export const unlinkComponent = async (componentUri: string): Promise<void> => {
return new Promise((resolve) => resolve());
} catch (e) {
console.log("Component Service - Failed to call /unlinkComponent");
const defaultMessage = "Failed to unlink components";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.unlinkComponent")));
}
};

Expand All @@ -207,8 +197,7 @@ export const remove = async (componentIri: string): Promise<void> => {
return new Promise((resolve) => resolve());
} catch (e) {
console.log("Component Service - Failed to call /remove");
const defaultMessage = "Failed to remove component";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.component.remove")));
}
};

Expand Down Expand Up @@ -239,8 +228,7 @@ export const addFailureModeByURI = async (componentUri: string, failureModeUri:
return new Promise((resolve) => resolve());
} catch (e) {
console.log("Component Service - Failed to call add failure mode by URI");
const defaultMessage = "Failed to add existing failure mode";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.failureMode.add")));
}
};

Expand All @@ -265,8 +253,7 @@ export const addFailureMode = async (componentUri: string, failureMode: FailureM
} catch (e) {
console.log("Component Service - Failed to call create failure mode");
console.log(e);
const defaultMessage = "Failed to create failure mode";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.failureMode.create")));
}
};

Expand All @@ -281,7 +268,6 @@ export const removeFailureMode = async (componentIri: string, failureModeUri: st
return new Promise<void>((resolve) => resolve());
} catch (e) {
console.log("Component Service - Failed to call /removeFailureMode");
const defaultMessage = "Failed to remove failure mode";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.failureMode.remove")));
}
};
Loading
Loading