HeliosLauncher/app/assets/js/renderer/langrenderer.js

30 lines
645 B
JavaScript
Raw Normal View History

2023-11-25 15:34:04 -08:00
// 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)
}