This commit is contained in:
nurmuhammet committed 2024-09-01 18:54:23 +05:00
1 parent 76d18365a5
commit 061f09eca1
1597 files changed
+109451 -1

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import forEach from 'lodash/forEach'
export default function __(key, replace) {
let translation = Nova.config('translations')[key]
? Nova.config('translations')[key]
: key
forEach(replace, (value, key) => {
key = new String(key)
if (value === null) {
console.error(
`Translation '${translation}' for key '${key}' contains a null replacement.`
)
return
}
value = new String(value)
const searches = [
':' + key,
':' + key.toUpperCase(),
':' + key.charAt(0).toUpperCase() + key.slice(1),
]
const replacements = [
value,
value.toUpperCase(),
value.charAt(0).toUpperCase() + value.slice(1),
]
for (let i = searches.length - 1; i >= 0; i--) {
translation = translation.replace(searches[i], replacements[i])
}
})
return translation
}