You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to add i18next to the maizzle config.
I have added a translations.json file and added it to server watch array. My code to add i18next looks like this
import i18next from "i18next";
/** @type {import('@maizzle/framework').Config} */
export default {
t: i18next.t,
lang: "en",
build: {
content: ["src/templates/**/*.html"],
static: {
source: ["src/images/**/*.*"],
destination: "images",
},
},
server: {
port: 8080,
reportFileSize: true,
watch: ["./src/images/translations.json"],
},
async beforeCreate({ config }) {
try {
// TODO: setting config should work from here as expected. Commenting code here as config is coming as undefined
// config.language = process.env.TEMPLATELANGUAGE || "en";
console.log(
"------------------------------------- running beforecreate --------------------------------"
);
const translations = await import("./src/images/translations.json", {
assert: { type: "json" },
});
const lang = process.env.TEMPLATELANGUAGE || "en";
// Await is important here to not let build advance before i18next has had time to finish initialization.
await i18next.init({
lng: lang,
fallbackLng: "en",
debug: false,
resources: translations.default,
});
} catch (error) {
console.log("error in config.js beforeCreate", error);
}
},
async beforeRender({ html, config, matter }) {
console.log("process.env ", process.env.TEMPLATELANGUAGE);
config.language = process.env.TEMPLATELANGUAGE || "en";
},
};
ISSUE 1 - However on changing the translations file, preview in browser is not refreshed not even on refresh. I need to start the server again to see the changes. ISSUE 2 - config in beforeCreate function is coming as undefined therefore we cant add anything to it
The text was updated successfully, but these errors were encountered:
I am trying to add i18next to the maizzle config.
I have added a translations.json file and added it to server watch array. My code to add i18next looks like this
ISSUE 1 - However on changing the translations file, preview in browser is not refreshed not even on refresh. I need to start the server again to see the changes.
ISSUE 2 - config in beforeCreate function is coming as undefined therefore we cant add anything to it
The text was updated successfully, but these errors were encountered: