Skip to content
Snippets Groups Projects
Commit 8b6bd8fe authored by Nik | Klampfradler's avatar Nik | Klampfradler Committed by Hangzhi Yu
Browse files

Merge message loading into aleksisAppImporter

parent 21c86b90
No related branches found
No related tags found
2 merge requests!1123Resolve "Finalise Vuetify app as SPA",!1066Translations update from Weblate
Pipeline #106989 canceled
import appDetails from "aleksisAppDetails";
import { appMessages } from "aleksisAppImporter";
for (const details of Object.values(appDetails)) {
if (details.hasMessages) {
import(details.assetDir + "/messages.json").then(function (appMessages) {
window.i18n.registerLocale(appMessages);
});
}
for (const messages of Object.values(appMessages)) {
window.i18n.registerLocale(messages);
}
......@@ -13,6 +13,7 @@ const django_values = JSON.parse(fs.readFileSync("./django-vite-values.json"));
function generateAppImporter(appDetails) {
let code = "let appObjects = {};\n";
code += "let appMessages = {};\n";
for (const [appPackage, appMeta] of Object.entries(appDetails)) {
let indexPath = appMeta.assetDir + "/index.js";
let importAppName =
......@@ -21,20 +22,14 @@ function generateAppImporter(appDetails) {
code += `console.debug("Importing AlekSIS app entrypoint for ${appPackage}");\n`;
code += `import ${importAppName} from '${indexPath}';\n`;
code += `appObjects["${appMeta.name}"] = ${importAppName};\n`;
if (appMeta.hasMessages) {
let messagesPath = appMeta.assetDir + "/messages.json";
code += `import ${importAppName}Messages from '${messagesPath}';\n`;
code += `appMessages["${appMeta.name}"] = ${importAppName}Messages;\n`;
}
}
code += "export default appObjects;\n";
return code;
}
function generateAppDetails(appDetails) {
let code = "let messages = {};\n";
for (const [appPackage, appMeta] of Object.entries(appDetails)) {
code += `messages["${appMeta.name}"] = JSON.parse('${JSON.stringify(
appMeta
)}');\n`;
}
code += "export default messages;\n";
code += "export { appObjects, appMessages };\n";
return code;
}
......@@ -93,7 +88,6 @@ export default defineConfig({
plugins: [
virtual({
aleksisAppImporter: generateAppImporter(django_values.appDetails),
aleksisAppDetails: generateAppDetails(django_values.appDetails),
}),
vue(),
nodeResolve({ modulePaths: [path.resolve("./node_modules")] }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment