import hyphenopoly from "../hyphenopoly.module.js";

// For local node:
// import hyphenopoly from "../hyphenopoly.module.js";

const hyphenator = hyphenopoly.config({
    "exceptions": {
        "en-us": "en-han-ces"
    },
    "hyphen": "•",
    "loader": async (file) => {
        const {readFile} = await import("node:fs/promises");
        const {dirname} = await import("node:path");
        const {fileURLToPath} = await import("node:url");
        const cwd = dirname(fileURLToPath(import.meta.url));
        return readFile(`${cwd}/../patterns/${file}`);
    },
    "require": ["de", "en-us"]
});

async function hyphenateEn(text) {
    const hyphenateText = await hyphenator.get("en-us");
    console.log(hyphenateText(text));
}

async function hyphenateDe(text) {
    const hyphenateText = await hyphenator.get("de");
    console.log(hyphenateText(text));
}

hyphenateEn("hyphenation enhances justification.");
hyphenateDe("Silbentrennung verbessert den Blocksatz.");
