2021-08-31 18:09:59 +02:00
|
|
|
import { toolsext } from '@src/store/Modules/toolsext'
|
|
|
|
|
import { tools } from '@src/store/Modules/tools'
|
|
|
|
|
import messages from '../statics/i18n'
|
|
|
|
|
|
|
|
|
|
function translate(params: any) {
|
2022-10-27 11:18:31 +02:00
|
|
|
if (!params)
|
|
|
|
|
return ''
|
|
|
|
|
|
2021-08-31 18:09:59 +02:00
|
|
|
const msg = params.split('.')
|
|
|
|
|
const lang = toolsext.getLocale()
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
|
const stringa = messages[lang]
|
|
|
|
|
|
|
|
|
|
let ris = stringa
|
2022-01-12 00:38:31 +01:00
|
|
|
try {
|
|
|
|
|
if (ris) {
|
|
|
|
|
msg.forEach((param: any) => {
|
|
|
|
|
ris = ris[param]
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
console.log('ERRORE IN TRANSLATE! ', params, ' NON ESISTE!')
|
|
|
|
|
return params
|
|
|
|
|
}
|
|
|
|
|
}catch (e) {
|
2021-08-31 18:09:59 +02:00
|
|
|
return params
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ris
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default translate
|