HeliosLauncher/app/assets/js/renderer/langrenderer.js
2023-11-25 18:34:35 -05:00

30 lines
645 B
JavaScript

// HACK FIXME
let lang
export async function loadLanguage() {
lang = await window.api.Lang.getLang()
}
export function query(id, placeHolders){
let query = id.split('.')
let res = lang
for(let q of query){
res = res[q]
}
let text = res === lang ? '' : res
if (placeHolders) {
Object.entries(placeHolders).forEach(([key, value]) => {
text = text.replace(`{${key}}`, value)
})
}
return text
}
export function queryJS(id, placeHolders){
return query(`js.${id}`, placeHolders)
}
export function queryEJS(id, placeHolders){
return query(`ejs.${id}`, placeHolders)
}