Adding translation for ressource titles
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user