Skip to content

Commit 7fac13d

Browse files
committed
feat: add options parameter to file function for enhanced translation support
1 parent 38bb2f4 commit 7fac13d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/server.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ const mimeTypes = {
8383
".7z": "application/x-7z-compressed"
8484
};
8585

86-
module.exports = async function file(CoCreateConfig, configPath, match) {
86+
module.exports = async function file(
87+
CoCreateConfig,
88+
configPath,
89+
match,
90+
options
91+
) {
8792
let directories = CoCreateConfig.directories;
8893
let sources = CoCreateConfig.sources;
8994
let configDirectoryPath = path.dirname(configPath);
@@ -280,6 +285,20 @@ module.exports = async function file(CoCreateConfig, configPath, match) {
280285
object
281286
};
282287

288+
if (
289+
options.translate &&
290+
mimeType === "text/html" &&
291+
Array.isArray(directory.languages) &&
292+
!object.translations
293+
) {
294+
// Call your AI translation service
295+
const translations = await options.translate(
296+
source,
297+
directory.languages
298+
);
299+
newObject.object.translations = translations;
300+
}
301+
283302
if (directory.storage) newObject.storage = directory.storage;
284303
if (directory.database) newObject.database = directory.database;
285304
if (directory.array) newObject.array = directory.array || "files";

0 commit comments

Comments
 (0)