Adding translation for ressource titles

This commit is contained in:
2025-04-29 23:05:51 +02:00
parent 1ba9a66c8e
commit 76143a9c2f
4 changed files with 77 additions and 33 deletions

View File

@@ -26,6 +26,7 @@ function convertCamelToSnake(str: string): string {
function buildResource(rawSchemas: RJSFSchema, resourceName: string) {
let resource;
const shortResourceName = convertCamelToSnake(resourceName.replace(/(-Input|Create|Update)$/g, ""));
resource = structuredClone(rawSchemas.components.schemas[resourceName]);
resource.components = { schemas: {} };
for (let prop_name in resource.properties) {
@@ -51,11 +52,12 @@ function buildResource(rawSchemas: RJSFSchema, resourceName: string) {
}
if (prop.hasOwnProperty("title")) {
const shortResourceName = convertCamelToSnake(resourceName.replace(/(-Input|Create|Update)$/g, ""));
prop.title = i18n.t(`schemas.${shortResourceName}.${convertCamelToSnake(prop_name)}`, prop.title);
console.log(`schemas.${shortResourceName}.${convertCamelToSnake(prop_name)}`);
}
}
if (resource.hasOwnProperty("title")) {
resource.title = i18n.t(`schemas.${shortResourceName}.resource_title`, resource.title);
}
return resource;
}