Skip to content

Commit

Permalink
unspecified
Browse files Browse the repository at this point in the history
  • Loading branch information
helagro committed Mar 17, 2024
1 parent ba9bec8 commit 7e1e27d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
40 changes: 19 additions & 21 deletions compile.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
const Handlebars = require("handlebars")
const fs = require("fs")


const languages = [
{
inputName: "english.json",
outputName: "index.html"
},
{
inputName: "swedish.json",
outputName: "se.html"
},
{
inputName: "english.json",
outputName: "en.html",
},
{
inputName: "swedish.json",
outputName: "se.html",
},
]


for(const language of languages){
compileLanguage(language)
for (const language of languages) {
compileLanguage(language)
}

function compileLanguage(lang){
const templateSource = fs.readFileSync("source/template.html", "utf8")
const contentStr = fs.readFileSync(`source/${lang.inputName}`, "utf8")
function compileLanguage(lang) {
const templateSource = fs.readFileSync("source/template.html", "utf8")
const contentStr = fs.readFileSync(`source/${lang.inputName}`, "utf8")

const contentObj = JSON.parse(contentStr)
const template = Handlebars.compile(templateSource)
const result = template(contentObj)
fs.writeFileSync(`docs/${lang.outputName}`, result)
}
const contentObj = JSON.parse(contentStr)
const template = Handlebars.compile(templateSource)
const result = template(contentObj)

fs.writeFileSync(`docs/${lang.outputName}`, result)
}
2 changes: 1 addition & 1 deletion source/swedish.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@
],
"otherLanguage": {
"name": "English",
"file": "index.html"
"file": "en.html"
}
}

0 comments on commit 7e1e27d

Please sign in to comment.