1
0
mirror of https://github.com/Qortal/qortal-ui.git synced 2025-07-22 12:24:18 +00:00
Files
build
config
core
assets
config
emoji
exports
font
language
memory-pow
public
server
sound
src
tooling
translate
directives
config.js
helpers.js
index.js
model.js
util.js
ui-core.js
crypto
img
lib
locales
plugins
scripts
snap
splash
.editorconfig
.gitattributes
.gitignore
CONTRIBUTING.md
LICENSE
README.md
build-setup.js
build.bat
build.js
build.sh
electron-builder.yml
electron.js
package-lock.json
package.json
run_server.bat
server.js
set-up-snap.sh
watch-inline.js
watch.js
qortal-ui/core/translate/helpers.js
AlphaX-Projects fa29ff4c43 Update UI
Refactor and added new functioms
2024-05-08 13:16:23 +02:00

18 lines
536 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export function interpolate(text, values, config) {
return Object.entries(extract(values || {})).reduce((text, [key, value]) => text.replace(new RegExp(`{{[  ]*${key}[  ]*}}`, `gm`), String(extract(value))), text)
}
export function lookup(key, config) {
const parts = key.split(".")
let string = config.strings
while (string != null && parts.length > 0) {
string = string[parts.shift()]
}
return string != null ? string.toString() : null
}
export function extract(obj) {
return (typeof obj === "function") ? obj() : obj
}