According documentation I made a helpres.ts plugin file with translate method which I would like to use inside components.
import { useAppStore } from '@/store/app'
export default {
install: (app) => {
const appStore = useAppStore()
app.config.globalProperties.$translate = (translations, key) => {
let defaultTranslation = translations[key] ? translations[key][0] : '' // First item as default value or ''
const translation = translations.find((item, key) => {
if ( item[key] && item[key].locale == appStore.defaultLang.val ) {
return true;
}
});
return translation ? translation : defaultTranslation
}
}
}
Then I register plugin in main.ts this way
import helpers from './plugins/helpers';
app.use(helpers)
But documentation does not mention how to use plugins inside components. How can I call helpres.translate inside the code and inside templates?