🌐 AI搜索 & 代理 主页
Skip to content

Commit a6d8b62

Browse files
committed
Improve compatibilty with @nuxt/text-utils
1 parent ad128fb commit a6d8b62

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { FluentBundle, FluentResource, FluentVariable } from '@fluent/bundle'
22
import type { TranslationWithAttrs } from './TranslationContext'
33
import type { FluentVueOptions } from './types'
4-
import type { InstallFunction, Vue2, Vue3, Vue3Component } from './types/typesCompat'
5-
import { isVue3, shallowRef } from 'vue-demi'
4+
import type { InstallFunction, Vue2, Vue3 } from './types/typesCompat'
5+
import { getCurrentInstance, isVue3, shallowRef } from 'vue-demi'
66

77
import { registerFluentVueDevtools } from './devtools'
88

@@ -83,13 +83,15 @@ export function createFluentVue(options: FluentVueOptions): FluentVue {
8383
key: string,
8484
value?: Record<string, FluentVariable>,
8585
) {
86-
return getContext(rootContext, this as Vue3Component).format(key, value)
86+
const instance = getCurrentInstance()
87+
return getContext(rootContext, instance?.proxy).format(key, value)
8788
}
8889
vue3.config.globalProperties[resolvedOptions.globalFormatAttrsName] = function (
8990
key: string,
9091
value?: Record<string, FluentVariable>,
9192
) {
92-
return getContext(rootContext, this as Vue3Component).formatAttrs(key, value)
93+
const instance = getCurrentInstance()
94+
return getContext(rootContext, instance?.proxy).formatAttrs(key, value)
9395
}
9496

9597
vue3.directive(resolvedOptions.directiveName, createVue3Directive(rootContext))

0 commit comments

Comments
 (0)