Skip to content

Commit

Permalink
[#550] Localize frontend errors messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
palagdan committed Sep 12, 2024
1 parent f848fff commit b1ddee9
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 194 deletions.
102 changes: 88 additions & 14 deletions public/locales/cs/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,102 @@
"save": "Uložit",
"discard": "Zahodit"
},
"errors": {

"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}}"
},
"faultTree": {
"rootEvent": {
"deleteViolation": "Kořenová událost stromu nesmí být smazána!"
}
"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}}"
},
"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}}"
},
"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é!"
"incorrectOldPassword": "Stará heslo je nesprávné!"
},
"impersonation": {
"adminImpersonation": "Nelze se vydávat za správce."
}
},
"faultTreeTraversal": {
"intermediateEventAsLeaf": "Mezilehlá událost nesmí být na konci cesty!"
},
"externalService": {
"configuration": {
"failureRateServiceNotSet": "Konfigurační parametr operationalFailureRateService není nastaven."
}
"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}}"
}
}
}
95 changes: 84 additions & 11 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,89 @@
"save": "Save",
"discard": "Discard"
},
"errors": {
"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}}"
},
"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}}"
},
"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}}"
},
"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": {
Expand All @@ -134,15 +212,10 @@
},
"impersonation": {
"adminImpersonation": "Cannot impersonate admin."
}
},
"faultTreeTraversal": {
"intermediateEventAsLeaf": "Intermediate event must not be the end of the path!"
},
"externalService": {
"configuration": {
"failureRateServiceNotSet": "Configuration parameter operationalFailureRateService not set."
}
},
"register": "Registration failed. {{error}}",
"login": "Login failed. {{error}}",
"passwordChange": "Password change failed. {{error}}"
}
}
}
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")));
}
};
6 changes: 2 additions & 4 deletions src/services/documentService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export const importDocument = async (systemUri: string, documentId: string): Pro
return new Promise((resolve) => resolve());
} catch (e) {
console.log("Document Service - Failed to call /import");
const defaultMessage = "Failed to import document";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.document.import")));
}
};

Expand All @@ -38,7 +37,6 @@ export const findAll = async (): Promise<DocumentModel[]> => {
return JsonLdUtils.compactAndResolveReferencesAsArray<DocumentModel>(response.data, CONTEXT);
} catch (e) {
console.log("Document Service - Failed to call /findAll");
const defaultMessage = "Failed to load documents";
return new Promise((resolve, reject) => reject(handleServerError(e, defaultMessage)));
return new Promise((resolve, reject) => reject(handleServerError(e, "error.document.findAll")));
}
};
Loading

0 comments on commit b1ddee9

Please sign in to comment.