makara icon indicating copy to clipboard operation
makara copied to clipboard

Makara doesn't look up localised templates

Open nerdgore opened this issue 9 years ago • 3 comments

Either I am missing something or makara seems to be broken. I followed the guide in the read me and set up makara as view engine:

// ...snip
const dustConfig = {
    cache: !config.development,
    helpers: [
        "dustjs-helpers",
        "dust-makara-helpers",
        debug,
        resolve(app),
        inline,
        adv
    ]
};

if (app.get("env") === "development") {
    app.set("views", path.join(config.root, "app/views"));
    app.engine("dust", makara.dust(dustConfig));
    app.set("view engine", "dust");
} else {
    // use cached, precompiled templates
    app.set("views", path.join(config.root, "build/app/views"));
    app.engine("js", makara.js(dustConfig));
    app.set("view engine", "js");
}

app.use(makara({
    i18n: {
        contentPath: path.join(config.root, "locales"),
        fallback: "de-DE"
    }
}));
// ...snip

Folder structure is ./build/app/views/DE/de/kaufberatung.js and so on. Looking at the debug output it seems that makara isn't even trying to look into the language folders.

ENGINE-MUNGER 24031: specialization mapped 'kaufberatung.js' to 'kaufberatung.js'
ENGINE-MUNGER 24031: lookup "kaufberatung.js"
ENGINE-MUNGER 24031: stat "~/workspace/project/build/app/views/kaufberatung.js"
ENGINE-MUNGER 24031: stat "~/workspace/project/build/app/views/kaufberatung.js/index.js"

Looking at the code in makara/index.js it seems like there should be some code to setup i18n for .js files but all I can find is the .properties setup.

nerdgore avatar Aug 19 '15 16:08 nerdgore

Hi @nerdgore. I think that is a problem with our documentation. With makara2, you don't need to compile the dust to js any longer, at least as far as express is concerned. The only difference between development and production view engine configuration should be whether or not you enable caching.

Do you want to alter your open PR to address the documentation issue?

grawk avatar Aug 20 '15 16:08 grawk

Ah I see. I can certainly update the PR. It will be a week or two though.

The reason I needed precompiling was because of #69. Too many partials caused even the initial render to fail. I haven't had time to look further into this so far. A temporary workaround (for us at least) is to fall back to adaro and engine-munger without makara. So far this setup has been stable.

nerdgore avatar Aug 21 '15 12:08 nerdgore

Hi, I do more than just translations in my precompilation such as cachebusting. This is also the setup generated when running yo kraken. I'd be happy to see #74 merged, can't really see a reason not to support this.

oblador avatar Sep 11 '15 20:09 oblador