Skip to content

Commit 3ea33d8

Browse files
committed
Add type definitions for i18n component
1 parent 0df3aa3 commit 3ea33d8

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

index.d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// #region Vue 2
2+
import { PropType, DefineComponent } from 'vue-demi'
3+
import { FluentVariable } from '@fluent/bundle'
4+
25
declare module 'vue/types/vue' {
36
interface Vue {
47
$t: (key: string, values?: Record<string, unknown>) => string
@@ -13,6 +16,46 @@ declare module '@vue/runtime-core' {
1316
$t: (key: string, values?: Record<string, unknown>) => string
1417
$ta: (key: string, values?: Record<string, unknown>) => Record<string, string>
1518
}
19+
20+
interface GlobalComponents {
21+
i18n: DefineComponent<{
22+
/**
23+
* The key of the translation.
24+
*/
25+
path: {
26+
type: StringConstructor,
27+
required: true,
28+
},
29+
/**
30+
* Arguments to pass to the translation.
31+
*/
32+
args: {
33+
type: PropType<Record<string, FluentVariable>>,
34+
default: () => Record<string, FluentVariable>,
35+
},
36+
/**
37+
* The tag to use as a root element.
38+
*/
39+
tag: {
40+
type: StringConstructor,
41+
default: 'span',
42+
},
43+
/**
44+
* Whether to render translation as html.
45+
*/
46+
html: {
47+
type: BooleanConstructor,
48+
default: false,
49+
},
50+
/**
51+
* Whether to render translation without a root element.
52+
*/
53+
noTag: {
54+
type: BooleanConstructor,
55+
default: false,
56+
}
57+
}>
58+
}
1659
}
1760
// #endregion
1861

0 commit comments

Comments
 (0)