mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-27 19:29:23 +02:00
Update:More localization strings #1103
This commit is contained in:
parent
eb463a2958
commit
faac6f677a
46 changed files with 772 additions and 527 deletions
|
@ -2,8 +2,25 @@ import Vue from "vue"
|
|||
|
||||
const defaultCode = 'en-us'
|
||||
|
||||
function supplant(str, subs) {
|
||||
// source: http://crockford.com/javascript/remedial.html
|
||||
return str.replace(/{([^{}]*)}/g,
|
||||
function (a, b) {
|
||||
var r = subs[b]
|
||||
return typeof r === 'string' || typeof r === 'number' ? r : a
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Vue.prototype.$i18nCode = ''
|
||||
Vue.prototype.$strings = {}
|
||||
Vue.prototype.$getString = (key, subs) => {
|
||||
if (!Vue.prototype.$strings[key]) return ''
|
||||
if (subs && Array.isArray(subs) && subs.length) {
|
||||
return supplant(Vue.prototype.$strings[key], subs)
|
||||
}
|
||||
return Vue.prototype.$strings[key]
|
||||
}
|
||||
|
||||
var translations = {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue