const links = computed(() => {
return [
{ title: messagePlagin('Bill'), url: '/' },
{ title: messagePlagin('History'), url: '/history' },
{ title: messagePlagin('Planning'), url: '/planning' },
{ title: messagePlagin('Record'), url: '/record' },
{ title: messagePlagin('Categories'), url: '/categories' }
]
})
import { InjectionKey } from 'vue'
// InjectionKey<T>, где T представляет явно передаваемый тип, который отслеживается при provide/inject
export const localizeFilterKey: InjectionKey<(key: string) => string> = Symbol('lol')
import { inject, computed } from 'vue'
import { localizeFilterKey } from '@/interface/Injection-key-localize'
export default {
props: ['modelValue'],
setup() {
// const messagePlagin = inject(localizeFilterKey)
const messagePlagin = inject(localizeFilterKey)
const links = computed(() => {
return [
{ title: messagePlagin('Bill'), url: '/' },
{ title: messagePlagin('History'), url: '/history' },
{ title: messagePlagin('Planning'), url: '/planning' },
{ title: messagePlagin('Record'), url: '/record' },
{ title: messagePlagin('Categories'), url: '/categories' }
]
})
return {
links
}
}
}
import { localizeFilterKey } from '@/interface/Injection-key-localize'
const locales = {
'ru-RU': ru as string,
'en-US': en as string
}
export default {
install(app: any, options: any) {
const localizeFilter = app.config.globalProperties.$localizeFilter = (key: string) => {
const locale = store.getters['info/info'].locale || 'ru-RU' as string
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return locales[locale][key] || `[Localize error]: key ${key} not found`
}
// app.provide('localizeFilterKey', localizeFilter)
app.provide(localizeFilterKey, localizeFilterKey)
}
}