Updating translations and adding a translation tracker

This commit is contained in:
2025-04-28 18:55:06 +02:00
parent 14aea2a475
commit 1ba9a66c8e
11 changed files with 1487 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { JSONSchema7Definition } from "json-schema";
import { RJSFSchema } from '@rjsf/utils';
import i18n from '../../../i18n'
const API_URL = "/api/v1";
@@ -19,6 +19,10 @@ const getJsonschema = async (): Promise<RJSFSchema> => {
return rawSchema;
}
function convertCamelToSnake(str: string): string {
return str.replace(/([a-zA-Z])(?=[A-Z])/g,'$1_').toLowerCase()
}
function buildResource(rawSchemas: RJSFSchema, resourceName: string) {
let resource;
@@ -45,6 +49,12 @@ function buildResource(rawSchemas: RJSFSchema, resourceName: string) {
} else if (is_array(prop) && is_reference(prop.items)) {
resolveReference(rawSchemas, resource, prop.items);
}
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)}`);
}
}
return resource;
@@ -161,7 +171,6 @@ function path_exists(rawSchemas: RJSFSchema, resource: RJSFSchema, path: string)
return has_descendant(rawSchemas, resource, path);
}
return has_descendant(rawSchemas, resource, path.substring(0, pointFirstPosition))
&& path_exists(
rawSchemas,